We will reduce the following sum (note the value $n$ instead of $7$ cfr. OP):
$$\mathcal{S}=\sum_{k=0}^{n-1}\frac{1-z^2}{1-2z\cos\left(\frac{2\pi i k}{n}\right)+z^2}$$
In this answer, we will make use of the following:
The roots of the polynomial $z^n-1$ are $\left\{\omega^k:k=0,\cdots,n-1\right\}$ with:
$$\omega=\exp\left(\frac{2\pi i}{n}\right)$$
and $\omega^{-k}=\omega^{n-k}$.
The fundamental theorem of algebra:
$$ z^n-1 = \prod_{k=0}^{n-1}(z-\omega^k)$$
The geometric series:
$$g(z)=1+z+z^2+\cdots+z^{n-1}=\frac{z^n-1}{z-1}$$
Using (3), you find that
\begin{align}
g(\omega^k)=n&,\quad\textrm{if }k\textrm{ is a multiple of }n\\
g(\omega^k)=0&,\quad\textrm{if }k\textrm{ is not a multiple of }n
\end{align}
Step 1: Rewrite the denominator as: $(z-\omega^k)(z-\omega^{-k})$ :
$$\mathcal{S}=\sum_{k=0}^{n-1}\frac{1-z^2}{(z-\omega^k)(z-\omega^{-k})}.$$
Step 2: Split the fraction into two parts making use of
$$\frac{z^2-1}{z-\omega^k}=z + \frac{\omega^k(z-\omega^{-k})}{z-\omega^k},$$
which is obtained by long-division and leads to
$$ \mathcal{S}=-\sum_{k=0}^{n-1}\frac{z}{z-\omega^{-k}} - \sum_{k=0}^{n-1}\frac{\omega^k}{z-\omega^k}.$$
Step 3: Using (1), redfine the indices of the first sum ($n-k=k'$) and merge it with the second to reduce $\mathcal{S}$ into:
$$ \mathcal{S}=-\sum_{k=0}^{n-1}\frac{z+\omega^k}{z-\omega^k}.$$
Step 4: It is clear that this sum $\mathcal{S}$ is a rational function of two polynomials $p(z)$ and $q(z)$. The denominator $q(z)$ is quickly obtained from the fundamental theorem of algebra (2) when merging all fractions in $\mathcal{S}$. This gives
$$\mathcal S=-\frac{p(z)}{q(z)},\qquad\textrm{with}\qquad q(z)=z^n-1=\prod_{k=0}^{n-1}(z-\omega^k)$$
The polynomial $p(z)$ is then given by :
$$ p(z)=\sum_{k=0}^{n-1} (z+\omega^k) r_k(z), \qquad\textrm{with}\qquad r_k(z)=\frac{q(z)}{z-\omega^k}=\frac{z^n-1}{z-\omega^k}. $$
Step 5: Using the geometric Series $g(z)$ cfr.(3), we can write:
$$g\left(\frac{z}{\omega^{k}}\right)=\frac{z^n\omega^{-kn}-1}{z\omega^{-k}-1}={\omega^{k}}\cdot\frac{z^n-1}{z-\omega^k}$$
and thus
$$ r_k(z)=\omega^{-k}\left(1+\frac{z}{\omega^k}+\cdots+\frac{z^{n-1}}{\omega^{k(n-1)}}\right)=\omega^{-k}\sum_{m=0}^{n-1}\left(\frac{z}{\omega^k}\right)^m,$$
Step 6: Finaly we can determine $p(z)$ by looking at the powers of $z$. Plugging the values of $r_k(z)$ into the equation for $p(z)$ gives us:
$$p(z) = \sum_{k=0}^{n-1}\sum_{m=0}^{n-1}\left(\left(\frac{z}{\omega^k}\right)^{m+1} + \left(\frac{z}{\omega^k}\right)^{m}\right).$$
and making use of (4) we finally obtain
$$p(z) = n(z^n+1)$$
Which demonstrates that:
$$\bbox[5px,border:2px solid #00A000]{ \mathcal{S}=\sum_{k=0}^{n-1}\frac{1-z^2}{1-2z\cos\left(\frac{2\pi i k}{n}\right)+z^2} = -\frac{p(z)}{q(z)} = \frac{n(z^n+1)}{1-z^n}}$$