$\textbf{Alternative Method}:$
$$\\$$
Since,
$$z=x+iy, \text{ where } x,y \in \mathbb{R}.$$
$$\cos(z)=\frac{e^{iz}+e^{-iz}}{2}$$
Then,
$$\begin{align}\cos(z)=\cos(x+iy)&=\frac{e^{i(x+iy)}+e^{-i(x+iy)}}{2}\\&=
\frac{e^{-y+ix}+e^{y-ix}}{2}\\&=\frac{e^{-y}[\cos(x)+i\sin(x)]+e^{y}[\cos(-x)+i\sin(-x)]}{2}\\&=\frac{e^{-y}\cos(x)+ie^{-y}\sin(x)+e^{y}\cos(x)-e^{y}\sin(x)}{2},
\\\text{since } \cos(-x)=\cos(x) \text{ and }\sin(-x)=-\sin(x).\\&=\frac{\cos(x)(e^{-y}+e^y)+i\sin(x)(e^{-y}-e^y)}{2}\end{align}$$
Hence,
$$\begin{align}|\sin(z)|=|\sin(x+iy)|&=\Bigg|\frac{\cos(x)(e^{-y}+e^y)+i\sin(x)(e^{-y}-e^y)}{2} \Bigg|\\&=\frac{\Bigg|\cos(x)(e^{-y}+e^y)+i\sin(x)(e^{-y}-e^y)\Bigg|}{\Big|2\Big|}\\&=\frac{\sqrt{[\cos(x)(e^{-y}+e^y)]^2+[\sin(x)(e^{-y}-e^y)]^2}}{2}\end{align}$$
Thus,
$$\begin{align}|\sin(z)|^2=|\sin(x+iy)|^2&=\Bigg(\frac{\sqrt{[\cos(x)(e^{-y}+e^y)]^2+[\sin(x)(e^{-y}-e^y)]^2}}{2}\Bigg)^2\\&=\frac{[\cos(x)(e^{-y}+e^y)]^2+[\sin(x)(e^{-y}-e^y)]^2}{4}\\&=\frac{[\cos^2(x)(e^{-2y}+e^{2y}+2)]+[\sin^2(x)(e^{-2y}+e^2y-2)]}{4}\\&=\frac{e^{-2y}(\cos^2(x)+\sin^2(x))+e^{2y}(\cos^2(x)+\sin^2(x))+2(\cos^2(x)-\sin^2(x))}{4}\\&=\frac{e^{-2y}+e^{2y}+2(2\cos^2(x)-1)}{4}\\&=\frac{e^{-2y}+e^{2y}-2+4\cos^2(x)}{4}\\&=\frac{e^{-2y}+e^{2y}-2}{4}+\frac{4\cos^2(x)}{4}\\&=\sinh^2(y)+\cos^2(x)\end{align}$$
Note:
$$\sinh(y)=\frac{e^{y}-e^{-y}}{2}, \text{ where } y\in \mathbb{R}.$$
$$\begin{align}\sinh^2(y)&=\Bigg(\frac{e^{y}-e^{-y}}{2}\Bigg)^2\\&=\frac{e^{2y}+e^{-2y}-2}{4}\end{align}$$
Therefore, we have proven $|\cos(z)|^2=\cos^2(x)+\sinh^2(y)$ for all $z=x+iy$.