In this case, you can take the integral to be
$$\operatorname{Re}{\int_{-\infty}^{\infty} dx \frac{e^{i a x}}{x^2+x+1}} $$
Assume $a \gt 0$ for now. The roots of the denominator are at $x_{\pm} = -\frac12 \pm i \frac{\sqrt{3}}{2} = e^{\pm i 2 \pi/3}$.
Because we assumed $a \gt 0$, we consider the contour integral
$$\oint_C dz \frac{e^{i a z}}{z^2+z+1} $$
where $C$ is a semicircle in the upper half plane. By the residue theorem, we need only consider the pole at $x_+$. As the radius of the semicircle goes to infinity, we find that
$$\int_{-\infty}^{\infty} dx \frac{e^{i a x}}{x^2+x+1} = i 2 \pi \frac{e^{-\sqrt{3} a/2} e^{-i a/2}}{i \sqrt{3}} $$
Thus, when $a \gt 0$,
$$\int_{-\infty}^{\infty} dx \frac{\cos{a x}}{x^2+x+1} = \frac{2 \pi}{\sqrt{3}} e^{-\sqrt{3} a/2} \cos{\left ( \frac{a}{2} \right )} $$
When $a \lt 0$, we must use a contour in the lower-half plane. In this case, we use the residue at the pole at $x_-$. Thus, for all values of $a$:
$$\int_{-\infty}^{\infty} dx \frac{\cos{a x}}{x^2+x+1} = \frac{2 \pi}{\sqrt{3}} e^{-\sqrt{3} |a|/2} \cos{\left ( \frac{a}{2} \right )} $$