There exists a known function, Jacobi theta function, defined as
$$
\vartheta(z; \tau):=\sum_{n=-\infty}^\infty w^{n^2}\eta^n \tag1
$$
where $w=:e^{\pi/\tau}$ and where $\eta:=e^{2i\pi z} $.
You may have a look at many interesting properties of $\vartheta(\cdot;\cdot)$.
In particular, the Jacobi triple product tells us that for complex numbers $w$ and $q$ with $|q| < 1$ and $w ≠ 0$, we have
$$
\sum_{n=-\infty}^\infty w^{2n}q^{n^2}=\prod_{m=1}^\infty
\left( 1 - q^{2m}\right)
\left( 1 + w^{2}q^{2m-1}\right)
\left( 1 + w^{-2}q^{2m-1}\right).
$$
The following related finite sum has a closed form due to Gauss ($1801$)
$$
\sum_{k=0}^{N-1}\exp\left(\frac{2\pi{\rm i}n^2}N\right)=\begin{cases}(1+{\rm i})\sqrt N&{\rm if}\ N\equiv0\mod 4\\\sqrt N&{\rm if}\ N\equiv1\mod 4\\0&{\rm if}\ N\equiv2\mod 4\\{\rm i}\sqrt N&{\rm if}\ N\equiv3\mod 4.\end{cases}
$$