The answer is yes. To see this, consider the ring $R=\mathbb{Z}[\sqrt{-n}]$. If $z=p_1\dots p_k$ is the decomposition of $z$ into rational primes, then by assumption each $p_j$ decomposes in $R$ as $p_j=q_j\bar q_j$. We need to show that any decomposition $z=r\bar r$ in $R$ can be gotten as follows: for each $j$ let $r_j$ be either $q_j$ or $\bar q_j$, and then put $q=wr_1\dots r_k$, where $w$ is a unit in $R$. In $R$ the ideal $(z)$ decomposes into prime ideals as $(z)=(q_1)(\bar q_1)\dots (q_k)(\bar q_k)$, hence it suffices to show that in $R$ the ideal $(z)$ and its divisors decompose uniquely into prime ideals. If $n$ is square-free and congruent to $1$ or $2$ mod $4$, then $R$ is the full ring of integers in $\mathbb{Q}(\sqrt{-n})$, hence it is a Dedekind domain. So in this case we are done. If $n$ is square-free and congruent to $3$ mod $4$, then $R$ is a quadratic order of conductor $2$ in $\mathbb{Q}(\sqrt{-n})$, hence unique factorization holds in $R$ for ideals prime to $2$. Clearly, each $p_j$ above is odd, hence $(z)$ is coprime to $2$, and we are done. If $n$ is not square-free, then $R$ is a quadratic order of some conductor $f\mid n$ in $\mathbb{Q}(\sqrt{-n})$, hence unique factorization holds in $R$ for ideals prime to $f$. Clearly, each $p_j$ above is coprime to $n$, hence $(z)$ is coprime to $n$, and we are done. For the quoted result on quadratic orders see Exercise 7.26 in Cox: Primes of the form $x^2+ny^2$.