Example 4 Let $n>1$ be an odd number. Find the value of $\prod_{k=1}^{m} \cos \frac{a_{k} \pi}{n}$, where $a_{1}, a_{2}, \cdots, a_{m}$ are all positive integers not greater than $n$ and coprime with $n$.
Since $a_{1}, a_{2}, \cdots, a_{m}$ form a reduced residue system modulo $n$, and $(n, 2)=1$, then $2 a_{1}, 2 a_{2}, \cdots, 2 a_{m}$ also form a reduced residue system modulo $n$.
Thus, $\left|\prod_{k=1}^{m} \sin \frac{a_{k} \pi}{n}\right|=\left|\prod_{k=1}^{m} \sin \frac{2 a_{k} \pi}{n}\right|$
$=2^{m}\left|\prod_{k=1}^{m} \sin \frac{a_{k} \pi}{n}\right|\left|\prod_{k=1}^{m} \cos \frac{a_{k} \pi}{n}\right|$.
Since $\prod_{k=1}^{m} \sin \frac{a_{k} \pi}{n} \neq 0$, we have
$\left|\prod_{k=1}^{m} \cos \frac{a_{k} \pi}{n}\right|=\frac{1}{2^{m}}$.
Next, consider the sign of $\prod_{k=1}^{m} \cos \frac{a_{k} \pi}{n}$, which only requires determining the number of elements in $a_{1}, a_{2}, \cdots, a_{m}$ that are greater than $\frac{n}{2}$.
Assume without loss of generality that $0 < n-a_{1} > n-a_{2} > \cdots > n-a_{m} > 0$, and that $n-a_{i} (1 \leqslant i \leqslant m)$ also form a reduced residue system modulo $n$.
Thus, $a_{m+1-i}=n-a_{i} (1 \leqslant i \leqslant m)$.
Therefore, exactly half of $a_{1}, a_{2}, \cdots, a_{m}$ are greater than $\frac{n}{2}$
(Note that each $a_{i}$ is not equal to $\frac{n}{2}$).
$$
\begin{array}{l}
\text { Hence } \prod_{k=1}^{m} \cos \frac{a_{k} \pi}{n}=(-1)^{\frac{m}{2}}\left|\prod_{k=1}^{m} \cos \frac{a_{k} \pi}{n}\right| \\
=(-1)^{\frac{n}{2}} \frac{1}{2^{m}}(m=\varphi(n) \text { is even }) .
\end{array}
$$