Yes. Analogous questions motivated much of the early development of number theory. You can find a beautiful exposition on this and related topics in David Cox's book Primes of the form $x^2 + n y^2.$ Below is an excerpt from the introduction.
Most first courses in number theory or abstract algebra prove a theorem of
Fermat which states that for an odd prime p,
$$ p = x^2 + y^2,\ x,y \in \Bbb Z \iff p \equiv 1 \pmod 4.$$
This is only the first of many related results that appear in Fermat's works.
For example, Fermat also states that if p is an odd prime, then
$$\begin{eqnarray} p = x^2 + 2y^2,\ x,y \in \Bbb Z &\iff& p \equiv 1,3 \pmod 8 \\
\\
p = x^2 + 3y^2,\ x,y \in \Bbb Z &\iff& p \equiv 3\ \ {\rm or}\ \ p \equiv 1 \pmod 3.\end{eqnarray} $$
These facts are lovely in their own right, but they also make one curious
to know what happens for primes of the form $x^2 + 5y^2,\ x^2 + 6y^2,$ etc. This
leads to the basic question of the whole book, which we formulate as follows:
Basic Question 0.1. $\ $ Given a positive integer $n,$ which primes $p$ can be expressed in the form
$$ p = x^2 + n y^2 $$
where $x$ and $y$ are integers?
We will answer this question completely, and along the way we will encounter some remarkably rich areas of number theory. The first steps will
be easy, involving only quadratic reciprocity and the elementary theory of
quadratic forms in two variables over $\Bbb Z.$ These methods work nicely in the
special cases considered above by Fermat. Using genus theory and cubic
and biquadratic reciprocity, we can treat some more cases, but elementary
methods fail to solve the problem in general. To proceed further, we need
class field theory. This provides an abstract solution to the problem, but
doesn't give explicit criteria for a particular choice of $n$ in $x^2 + n y^2.$
The final step uses modular functions and complex multiplication to show that
for a given n, there is an algorithm for answering our question of when
$ p = x^2 + n y^2.$