Example 3 Given $|z|=1, k$ is a real number, $z$ is a complex number. Find the maximum value of $\left|z^{2}+k z+1\right|$.
Let $z=\cos q+\mathrm{i} \sin q$. Then
$$
\begin{array}{l}
z^{2}+k z+1 \\
=\cos 2 q+\mathrm{i} \sin 2 q+k(\cos q+\mathrm{i} \sin q)+1 \\
=(\cos 2 q+k \cos q+1)+\mathrm{i}(\sin 2 q+k \sin q) .
\end{array}
$$

Therefore, $|z^{2}+k z+1|$
$$
\begin{array}{l}
=\sqrt{(\cos 2 q+k \cos q+1)^{2}+(\sin 2 q+k \sin q)^{2}} \\
=\sqrt{4 \cos ^{2} q+4 k \cos q+k^{2}} \\
=|2 \cos q+k|
\end{array}
$$

Thus, $\left|z^{2}+k z+1\right|_{\max }=\left\{\begin{array}{ll}k+2, & k \geqslant 0 \text {; } \\ 2-k, & k<0 .\end{array}\right.$