Let $z=e^{i \theta}$, then $d\theta=dz/(i z)$ and $\sin{\theta} = (z-1/z)/(2 i)$. Then the integral becomes
$$\frac12\frac{-i}{(2 i)^{2 n}} \oint_{|z|=1} \frac{dz}{z} \left( z-z^{-1}\right)^{2 n} =\frac12 \frac{-i}{(2 i)^{2 n}} \oint_{|z|=1} dz \frac{(z^2-1)^{2 n}}{z^{2 n+1}}$$
As you can see, you have a pole of order $2 n+1$ in the integrand. To apply the residue Theorem, you need to evaluate $i 2 \pi$ times the residue at the pole at $z=0$, which is
$$\frac{\pi}{(2 i)^{2 n}} \frac{1}{(2 n)!} \left[\frac{d^{2 n}}{dz^{2 n}}\left ( z^2-1\right)^{2 n}\right]_{z=0}$$
Now, by Rodrigues' formula for Legendre polynomials, the latter expression is
$$\left[\frac{d^{2 n}}{dz^{2 n}}\left ( z^2-1\right)^{2 n}\right]_{z=0} = 2^{2 n} (2n)! P_n(0)$$
ADDENDUM
We can also use the binomial theorem to extract an explicit expression for the residue. Note that
$$\left ( z^2-1\right)^{2 n} = \sum_{k=0}^{2 n} \binom{2 n}{k} z^{2 k} (-1)^k$$
Taking the $2 n$th derivative and setting $z=0$ leaves only the $n$th term in the sum, so we get
$$\left[\frac{d^{2 n}}{dz^{2 n}}\left ( z^2-1\right)^{2 n}\right]_{z=0} = (-1)^n \frac{(2 n)!^2}{(n!)^2}$$
Therefore, the integral is
$$\frac{\pi}{2^{2 n}} \binom{2 n}{n}$$
Let $\theta=b$ and $B = -a \lt 0$. Then the first integral is a generalization of this integral. Using the same substitutions:
$u=a x+b/x$. Then $a x^2-u x+b = 0$, and therefore
$$x = \frac{u}{2 a} \pm \frac{\sqrt{u^2-4 a b}}{2 a}$$
$$dx = \frac1{2 a}\left (1 \pm \frac{u}{\sqrt{u^2-4 a b}}\right ) du $$
Now, it should be understood that as $x$ traverses from $0$ to $\infty$, $u$ traverses from $\infty$ down to a min of $2 \sqrt{a b}$ (corresponding to $x \in [0,\sqrt{b/a}]$), then from $2 \sqrt{a b}$ back to $\infty$ (corresponding to $x \in [\sqrt{b/a},\infty)$). Therefore the integral is
$$\frac1{2 a} \int_{\infty}^{2 \sqrt{a b}} du \, \left (\frac{u}{2 a} - \frac{\sqrt{u^2-4 a b}}{2 a} \right )^p \left (1 - \frac{u}{\sqrt{u^2-4 a b}}\right ) e^{-u} \\+ \frac1{2 a} \int_{2 \sqrt{a b}}^{\infty} du \, \left (\frac{u}{2 a} + \frac{\sqrt{u^2-4 a b}}{2 a} \right )^p \left (1 + \frac{u}{\sqrt{u^2-4 a b}}\right ) e^{-u} $$
which simplifies, subbing $u=2 \sqrt{a b} \cosh{v}$, to
$$\begin{align}\int_0^{\infty} dx \, x^p e^{-\left (a x+\frac{b}{x} \right )} &=2 \left (\sqrt{\frac{b}{a}} \right )^{p+1} \int_0^{\infty} dv \, \cosh{[(p+1) v]} \, e^{-2 \sqrt{a b} \cosh{v}} \\ &=2 \left (\sqrt{\frac{b}{a}} \right )^{p+1} K_{p+1} \left ( 2 \sqrt{a b}\right )\end{align}$$
Best Answer
It's an interesting integral. I think you are stuck on how to tackle $\theta$ sitting in the $cos(2\sin(\theta) - \theta)\,$. I will use complex integration to solve it.
Put $cos(2\sin(\theta) - \theta)\, = \Re\; e^{i(2\sin(\theta) - \theta)}$. Then the integral $I$ becomes $$I = \Re\int_0^\pi \,e^{2\cos(\theta)}e^{i(2\sin(\theta) - \theta)}\,\mathrm{d}\theta$$ Now I want to convert $I$ into a closed line integral and for that, I try the substitution $$\theta \rightarrow 2\pi-\theta$$ in the original integral. It is easy to see then that integral remains unchanged so, by the property of definite integrals for real variables, $$I = \frac{1}{2}\int_0^{2\pi} e^{2\cos(\theta)}\cos(2\sin(\theta) - \theta)\,d\theta$$
Put $$\int_0^{2\pi} e^{2\cos(\theta)}\cos(2\sin(\theta) - \theta)\,d\theta =\Re\int_0^{2\pi} \,e^{2\cos(\theta)}e^{i(2\sin(\theta) - \theta)}\,\mathrm{d}\theta = J$$ Then $I = J/2$. Now substitute $\cos(\theta) + i \sin(\theta) = z\;$ in $J\;$. Then clearly, $$\int_0^{2\pi}\,e^{2\cos(\theta)}e^{i(2\sin(\theta) - \theta)}\,\mathrm{d}\theta = -i\oint \limits_{|z|=1}\frac{e^{2z}}{z^2}\mathrm{d}z$$
Now, $0$ is the only point of singularity of the integrand in the complex integral. Further, it is a pole of order $2$ and its residue is given by $$Res(0)= \frac{2e^{2\times0}}{1!} = 2$$ Then, by applying Cauchy's Residue theorem, we get $$\oint_{|z|=1}\frac{e^{2z}}{z^2}\mathrm{d}z = 2\pi i \times (1 \times 2)= 4\pi i$$
Therefore, $I = J/2 = \frac{\Re(4\pi i \times (-i))}{2} = \frac{\Re(4\pi)}{2} = 2\pi.$