Is there any general idea about for which $d$, $\mathbb Z[\sqrt d]$ a principal ideal domain (PID)?
As for example $\mathbb Z[\sqrt{-1}]$ and $\mathbb Z[\sqrt 2] $ are PIDs, but $\mathbb Z[\sqrt{-5}] $ is not a PID.
Is there any general idea about for which $d$, $\mathbb Z[\sqrt d]$ a principal ideal domain (PID)?
As for example $\mathbb Z[\sqrt{-1}]$ and $\mathbb Z[\sqrt 2] $ are PIDs, but $\mathbb Z[\sqrt{-5}] $ is not a PID.
As stated your question is too general for us to have an answer - it's an open problem, but from what you said after that I think you meant to ask this more specific question instead: for negative integers $d$, when is the ring of integers of $\mathbb{Q}(\sqrt{d})$ a PID? To that we have an answer but the proof is highly non-trivial.
First note that this ring of integers is $\mathbb{Z}[\omega]$ where $\omega=\frac{1+\sqrt{d}}{2}$ if $d\equiv 1 \bmod 4$, and $\omega=\sqrt{d}$ if $d\equiv 2,3 \bmod 4$.
Then, due to Stark, 1966, we know that $\mathcal{O}_d$ is a PID $\iff d=$-1, -2 , -3 , -7, -11, -19, -43, -67, or -163.
Stark's proof is hard. But it is easier in the cases where you can show it's a PID by showing it's a Euclidian domain, which (for $d< 0$) is true $\iff d=-1,-2,-3,-7,$ or $-11$. Getting that part has to do with using the field norm and doing a lot of arithmetic. You should be able to find it in textbooks.