The formula $$\sum_{n=-\infty}^{+\infty} e^{-in^2x}$$ does not converge in any function space but it is perfectly valid in $\mathcal{D}'(\mathbb{R})$. When applied on a test function $\psi(x) = \eta(x) f(x)$, where $f$ is $C^\infty$ and $2\pi$-periodic and $\eta$ is a mollifier such that $$\sum_{m=-\infty}^{+\infty} \eta(x+2\pi m) = 1, \quad \forall x \in \mathbb{R},$$ it gives the following sum of Fourier coefficients $a_n$ of $f$ which converges absolutely: $$2\pi \sum_{n=-\infty}^{+\infty} a_{n^2}.$$ Note that if the square was not present, this would give the value of $2\pi f(0)$, in accordance with the well-known result that $$\sum_{n=-\infty}^{+\infty} e^{-inx} \buildrel \mathcal{D}' \over \longrightarrow 2\pi \delta_{2\pi}(x).$$
My question is if the summation of the $n^2$-th Fourier coefficients (or the $\mathcal{D}'$ functional yielding it) has any closed form just like the sum of each ($n$-th) Fourier coefficient (or the sum of $e^{-inx}$) has.
This may sound as an arbitrary question but my sum could be perceived as an extreme case of the sum defining Jacobi theta function $\theta_3$ which makes it worth more general interest.