How to evaluate this nonelementary integral?
The Laplace transform of $\cos x$ is $\frac{s}{1+s^2}$ and the inverse Laplace transform of $\frac{1}{x^p}$ is $\frac{s^{p-1}}{\Gamma(p)}$, hence $$ \int_{0}^{+\infty}\frac{\cos x}{x^p}\,dx = \frac{1}{\Gamma(p)}\int_{0}^{+\infty}\frac{s^p}{s^2+1}\,ds=\frac{1}{\Gamma(p)}\int_{0}^{\pi/2}\left(\tan u\right)^p\,du $$ equals $$ \begin{eqnarray*}\frac{1}{\Gamma(p)}\int_{0}^{1} v^p (1-v^2)^{-(p+1)/2}\,dv&=&\frac{1}{2\,\Gamma(p)}\int_{0}^{1}w^{(p-1)/2}(1-w)^{-(p+1)/2}\,dw\\& =& \frac{B\left(\tfrac{1+p}{2},\tfrac{1-p}{2}\right)}{2\,\Gamma(p)}\end{eqnarray*} $$ or $$ \frac{\Gamma\left(\frac{1+p}{2}\right)\Gamma\left(\frac{1-p}{2}\right)}{2\,\Gamma(p)}= \frac{\pi}{2\,\Gamma(p)\sin\left(\frac{\pi}{2}(p+1)\right)}=\frac{\pi}{2\,\Gamma(p)\cos\left(\frac{\pi p}{2}\right)}$$ as wanted. We have exploited the Beta function and the reflection formula for the $\Gamma$ function.
Your given integral is closely related to the Mellin transform and can be evaluated by using Ramanujan's Master Theorem.
Ramanujan's Master Theorem
Let $f(x)$ be an analytic function with a MacLaurin Expansion of the form $$f(x)=\sum_{k=0}^{\infty}\frac{\phi(k)}{k!}(-x)^k$$then the Mellin Transform of this function is given by $$\int_0^{\infty}x^{s-1}f(x)dx=\Gamma(s)\phi(-s)$$
Therefore expand the cosine function as Taylor series expansion to get
$$\begin{align} \mathfrak{I}=\int_0^{\infty}\cos(x)x^{-p}dx&=\int_0^{\infty}x^{-p}\sum_{n=0}^{\infty}(-1)^n\frac{x^{2n}}{(2n)!}dx \end{align}$$
In order to bring the above integral in the wanted form for the usage of Ramanujan's Master Theorem apply the substitution $x^2=u$. So we further get
$$\begin{align} \mathfrak{I}=\int_0^{\infty}x^{-p}\sum_{n=0}^{\infty}(-1)^n\frac{x^{2n}}{(2n)!}dx&=\int_0^{\infty}x^{-p}\sum_{n=0}^{\infty}\frac{1}{(2n)!}(-x^2)^ndx\\ &=\int_0^{\infty}u^{-p/2}\sum_{n=0}^{\infty}\frac{1}{(2n)!}(-u)^n\frac{du}{2\sqrt{u}}\\ &=\frac12\int_0^{\infty}u^{-(p+1)/2}\sum_{n=0}^{\infty}\frac{1}{(2n)!}(-u)^ndu\\ &=\frac12\int_0^{\infty}u^{-(p+1)/2}\sum_{n=0}^{\infty}\frac{n!/(2n)!}{n!}(-u)^ndu \end{align}$$
By using the relation $\Gamma(n)=(n-1)!$ which is valid for all $n\in\mathbb N$ we can consider the last integral as an application of Ramanujan's Master Theorem with $s=-\frac{p-1}2$ and $\phi(n)=\frac{\Gamma(n+1)}{\Gamma(2n+1)}$. By finally using the Theorem we obtain
$$\begin{align} \mathfrak{I}=\frac12\int_0^{\infty}u^{-(p+1)/2}\sum_{n=0}^{\infty}\frac{n!/(2n)!}{n!}(-u)^ndu&=\frac12\Gamma\left(-\frac{p-1}2\right)\frac{\Gamma\left(\frac{p-1}2+1\right)}{\Gamma\left(2\left(\frac{p-1}2\right)+1\right)}\\ &=\frac1{2\Gamma(p)}\Gamma\left(1+\frac{p-1}2\right)\Gamma\left(-\frac{p-1}2\right) \end{align}$$
Now by applying Euler's Reflection Formula with $z=1+\frac{p-1}2$ we moreover get
$$\begin{align} \mathfrak{I}=\frac1{2\Gamma(p)}\Gamma\left(1+\frac{p-1}2\right)\Gamma\left(-\frac{p-1}2\right)&=\frac1{2\Gamma(p)}\frac{\pi}{\sin\left(\pi\left(1+\frac{p-1}2\right)\right)}\\ &=\frac1{2\Gamma(p)}\frac{\pi}{\sin\left(\frac{p\pi}2+\frac{\pi}2\right)}\\ &=\frac1{2\Gamma(p)}\frac{\pi}{\cos\left(\frac{p\pi}2\right)} \end{align}$$
where within the last step the fundamental relation $\sin\left(x+\frac{\pi}2\right)=\cos(x)$ was used. Thus for the original integral $\mathfrak{I}$ we get
$$\mathfrak{I}=\int_0^{\infty}\cos(x)x^{-p}dx=\frac{\pi}{2\Gamma(p)\cos\left(p\frac{\pi}2\right)}$$
Hint: $\displaystyle\int_{0}^{\infty}\frac{\cos x}{x^p}dx= \text{Real part of}\:\int_{0}^{\infty}\frac{e^{iz}}{z^p}dz$ and use residue theorem. This has a pole of order $p$ hence the term $\Gamma (p)$ in the denominator.