The sequence $ ~x[n] = \cos(\omega_0 n) ~$ , $-\infty < n < \infty$, is neither absolutely nor square summable, therefore its DTFT formally does not exist; i.e., the DTFT sum does not converge to a finite number, but diverges to infinity.
Because of the extreme importance of that signal in the context of both the theory and the practice of signal processing, we would like to express its DTFT in an adequate and consistent manner under all operations of signal processing. One such possible representation makes use of the Dirac impulse functions with the following observation:
Let $x[n] = 1$, for all $n$, be a discrete-time (unstable) signal whose DTFT $X(\omega)$ given by the sum: $$ X(\omega) = \sum_{n=-\infty}^{\infty} 1 e^{-j \omega n} \tag{1} $$
This sum, resembles a CTFS (continous time Fourier series) synthesis relation, remembering the fact that the DTFT $X(\omega)$ is a periodic function of continuous -frequency $\omega$. Then the above sum in Eq.1 is re-interpreted as a CTFS synthesis as:
$$ X(\omega) = \sum_{n=-\infty}^{\infty} a_n e^{-j \frac{2\pi}{W} n \omega } \tag{2} $$ where $\frac{2\pi}{W}$ is the fundamental frequency with the fundamental period being $W = 2\pi$, and the CTFS coefficients are all $a_n = 1$. From CTFS pairs, we find the signal $X(\omega)$ whose CTFS coefficents are all $1$, as the Dirac impulse train :
$$ X(\omega) = 2\pi \sum_{n=-\infty}^{\infty} \delta(\omega - 2\pi n) \tag{3}$$
and using the CTFS analysis equation, we have :
$$
\begin{align}
a_n &= \frac{1}{2\pi} \int_{-\pi}^{\pi} \left( 2\pi \sum_{n=-\infty}^{\infty} \delta(\omega - 2\pi n) \right) e^{-j \frac{2 \pi}{2\pi} \omega n } d\omega \\\\ &= \frac{1}{2\pi} \int_{-\pi}^{\pi} 2\pi \delta(\omega) e^{-j \omega n } d\omega = 1 \tag{4}
\end{align}
$$
The integral in Eq.4 is identical to an inverse DTFT of the impulse function $2 \pi \delta(\omega)$, hence we deduce that the DTFT $X(\omega)$ of $x[n]=1$ is
$$ x[n] = 1 \implies X(\omega) = 2\pi \delta(\omega) \tag{5}$$
Having found the DTFT of the sequence $x[n]=1$, we apply an estabslihed property of the DTFT :
$$ x[n] \leftrightarrow X(\omega) \implies x[n]e^{j\omega_0 n} \leftrightarrow X(\omega - \omega_0) \tag{6}$$
$$ 1 \leftrightarrow 2 \pi \delta(\omega) \implies 1 \cdot e^{j\omega_0 n} \leftrightarrow 2\pi \delta(\omega - \omega_0) \tag{7} \\\\$$
to the seqeunce $x[n] = \cos(\omega_0 n)$ after decomposing it into complex exponentials:
$$
\begin{align}
x[n] &= \cos(\omega_0 n) = 0.5 \left( e^{j \omega_0 n} + e^{-j \omega_0 n} \right) \\ \\
X(\omega) &= \pi \delta( \omega - \omega_0) + \pi \delta(\omega + \omega_0)
\tag{8} \\ \\
\end{align}
$$
Eq.8 gives us the requested DTFT of the sequence $x[n] = \cos(\omega_0 n)$.