Assuming periodic boundary conditions (PBC):
$$
\begin{align}
\hat H =& t\sum_{i(\text{even})}^N \left(a_{i+1}^\dagger a_i + \text{h.c.}\right)=
t\sum_{j=1}^{N/2} \left(a_{2j+1}^\dagger a_{2j} + \text{h.c.}\right)=\\
=&t\sum_{j=1}^{N/2}\left[ \left(\frac{1}{\sqrt{N}}\sum_{\bf k}e^{-i{\bf k}(2j+1)}a_{\bf k}^\dagger\right)
\left(\frac{1}{\sqrt{N}}\sum_{\bf p}e^{i{\bf p} 2j} a_{\bf p}\right) + \text{h.c.}\right]=\\
=& t \sum_{\bf k,\bf p}\left[ a_{\bf k}^\dagger a_{\bf p} e^{-i\bf k}\frac{1}{N}\sum_{j=1}^{N/2} e^{-i({\bf k-p})2j}+\text{h.c}\right].
\end{align}
$$
Here variables ${\bf k,p}=\frac{2\pi}{N}n$, where $n\in\{0,1,\dots,N-1\}$.
Now let's focus on "wierd sum", but this is just a geometric series:
$$\frac{1}{N}\sum_{j=1}^{N/2} e^{-i({\bf k-p})2j} = \frac{1}{N}\sum_{j=1}^{N/2} \left(e^{-i({\bf k-p})2}\right)^j=
\begin{cases}
\tfrac{1}{2}, & \bf k=p;\\[1ex]
\frac{\displaystyle 1-e^{-2i({\bf k-p})N/2}}{\displaystyle 1-e^{-2i({\bf k-p})}}=0, & \bf k\neq p.
\end{cases}
$$
To summarize:
$$\frac{1}{N}\sum_{j=1}^{N/2} e^{-i({\bf k-p})2j} = \tfrac{1}{2} \delta_{\bf kp},$$
where $\delta_{\bf kp}$ is Kronecker delta.
Now come back to Hamiltonian:
$$\hat H = t \sum_{\bf k,\bf p}\left[ a_{\bf k}^\dagger a_{\bf p} e^{-i\bf k}\tfrac{1}{2}\delta_{\bf kp}+\text{h.c}\right]=\frac{t}{2}\sum_{\bf k} a_{\bf k}^\dagger a_{\bf k}\left(e^{-i\bf k}+e^{+i\bf k}\right)
=
t\sum_{\bf k} a_{\bf k}^\dagger a_{\bf k}\cos \bf k.
$$