There are going to be very few of these that come out so cleanly. There is not going to be anything clean unless there is only one class per genus "idoneal" (your discriminant $-4N$), and I would not really be confident unless there is only one class entirely for that discriminant. In the latter case, we have your $N=1,2,3,4,7.$

For possibilities with more general types of expressions, see BERKOVICH

Here we go, Leonard Eugene Dickson, *Introduction to the Theory of Numbers* (1929), exercises on pages 80-81, for section 51. If $m$ is positive and odd, the number of representations of $2^k m$ by $x^2 + 2 y^2$ is double the excess of the number of divisors $\equiv 1 \; \mbox{or} \; 3 \pmod 8$ of $m$ over the number of divisors $\equiv 5 \; \mbox{or} \; 7 \pmod 8$ of $m.$

The number of representations of any positive $n$ by $x^2 + x y + y^2$ is $6E(n),$ where
$E(n)$ is excess of the number of divisors $\equiv 1 \pmod 3$ of $n$ over the number of divisors $\equiv 2 \pmod 3$ of $n.$ Also, if $n=2^k m$ with $m$ odd, then $E(n)=0$ when $k$ is odd, while $E(n) = E(m)$ when $k$ is even.

Using the same $E(n)$ as above, the number of representations of $2^k m$ with $m$ odd by $x^2 + 3 y^2$ is $0$ if $k$ is odd, $2E(m)$ if $k=0,$ and $6 E(m) $ if $k$ is even and nonzero.

Dickson sticks with one class per discriminant on pages 80-81, then allows one class per genus on pages 84-86.

Note that we cannot expect such simple formulas when there are more than one classes per genus. If there were pretty formulas, we would have a simple way to decide whether an individual prime were represented. However, for example, a prime $p \equiv 1 \pmod 3$ is represented by $x^2 + 27 y^2$ if and only if 2 is a cubic residue $\pmod p.$ If $p \neq 7,2$ and $(-14|p) = 1,$ then $p = u^2 + 14 v^2$ is possible in integers if and only if there is an integer solution to $(z^2 + 1)^2 \equiv 8 \pmod p.$

Here is a good one. If $m$ is positive and odd, the number of representations of $m$ by $x^2 + xy + 3 y^2$ is double the excess of the number of divisors $\equiv 1, \; 3, \; 4, \; 5, \; \mbox{or} \; 9 \pmod {11}$ of $m$ over the number of divisors $\equiv 2, \; 6, \; 7, \; 8, \; \mbox{or} \; 10 \pmod {11}$ of $m.$ Now, a subset of these numbers is represented by $x^2 + 11 y^2,$ by a simple formula. However, for a single prime, if $p > 11$ has
$ (-44 | p) = 1,$ then we have an integral representation $p = u^2 + 11 v^2$ if and only if $z^3 + z^2 - z + 1 \equiv 0 \pmod p$ has an integral solution. But there is always a representation $ p = x^2 + x y + 3 y^2$ as soon as $ (-44 | p) = 1.$

In case of interest, the primes up to 500 represented by $x^2 + 11 y^2$ are

11
47
53
103
163
199
257
269
311
397
401
419
421
499

while the primes up to 500 represented by $3 x^2 \pm 2 x y + 4 y^2$ are

3
5
23
31
37
59
67
71
89
97
113
137
157
179
181
191
223
229
251
313
317
331
353
367
379
383
389
433
443
449
463
467
487