Let $n$ and $k$ be positive integers. When $n$ is odd, one can show that: $$\sum_{j=0}^{2^{k-1}-1}\cos^{n}\left(\pi\frac{2j+1}{2^{k-1}}\right)=\begin{cases} -1 & \textrm{if }k=1\\ 0 & \textrm{if }k\geq2 \end{cases}$$
I'm having some trouble dealing with the case where $n$ is even. Applying the identity: $$\cos^{n}\theta=\frac{1}{2^{n}}\binom{n}{n/2}+\frac{2}{2^{n}}\sum_{\ell=0}^{\frac{n}{2}-1}\binom{n}{\ell}\cos\left(\left(n-2\ell\right)\theta\right)$$ which holds when $n$ is even, the difficulty in dealing with the sum reduces to evaluating:
$$\sum_{\ell=0}^{\frac{n}{2}-1}\binom{n}{\ell}\sum_{j=0}^{2^{k-1}-1}\cos\left(\left(n-2\ell\right)\pi\frac{2j+1}{2^{k-1}}\right)$$ Using Ramanjuan sums, this reduces to: $$\sum_{\ell=0}^{\frac{n}{2}-1}\binom{n}{\ell}\sum_{j=0}^{2^{k-1}-1}\cos\left(\left(n-2\ell\right)\pi\frac{2j+1}{2^{k-1}}\right)=\sum_{\ell=0}^{\frac{n}{2}-1}\binom{n}{\ell}\left(2^{k}\left[n\overset{2^{k}}{\equiv}2\ell\right]-2^{k-1}\left[n\overset{2^{k-1}}{\equiv}2\ell\right]\right)$$ where $\left[\cdot\right]$ is the Iverson bracket notation, evaluating to $1$ when the enclosed statement is true and $0$ otherwise. Here $\overset{a}{\equiv}$ means “congruent modulo $a$”.
I'm having difficulty finding a closed-form expression for the sum on the right. Help would be much appreciated.