The requested generalization of Jacobi's two-square theorem is a remarkably recent result: N. Bagis and M.L Glasser, <A HREF="http://arxiv.org/abs/1406.0466">On the Number of Representations of Integers by various Quadratic and Higher Forms</A> (2015): <IMG SRC="http://ilorentz.org/beenakker/MO/sumofsquares_2.png"/> where $r(n)$ is Jacobi's formula for the number of representations of $n=x^2+y^2$. --- I understand from the comments that this (general but complicated) formula is not what the OP was looking for. Berkovich and Yesilyurt in <A HREF="http://arxiv.org/abs/math/0611300">Ramanujan's Identities and Representation of Integers by Certain Binary and Quaternary Quadratic Forms</A> (2006) give rather simple expressions for specific cases of $n=x^2+ay^2$. I reproduce below the result for $a=5$, and there are others (6,15,27,...). As explained in this <A HREF="http://mathoverflow.net/questions/85741/representations-by-positive-definite-binary-quadratic-forms/85763#85763">2012 MO posting,</A> there is no simple Jacobi-type formula that will apply to any $a$. <IMG SRC="http://ilorentz.org/beenakker/MO/arXiv_0611300.png"/>