What to say to one PhD offer when still waiting to hear the result of a different and preferred PhD application? I have had two PhD interviews. One of the position (position A) I like more than the other (position B).

Now, I have gotton a reply from position B saying that they will offer me the PhD. However, before replying yes/no, I would like to know what the response is from position A.

Will it be good practice to let position B know that I will answer them once I know what the status is of my other application? Or is this sharing too much information?
The usual thing to do in this situation is to ask B when they need your response.  If that isn't enough time to hear back from A, then it's fine to ask B if you can have more time to decide (you don't need to say why).  Of course, they might say that they cannot give you more time, in which case you'll have to make a decision on B without knowing about A.

There's nothing wrong with wanting to consider all your options, and the people from B will undoubtedly read between the lines and understand that this is the situation, but you don't need to rub their nose in the fact that you'd rather be somewhere else.

To echo Pavel's answer, whatever decision you do give to B, you should stick with.  If B gives you a short deadline, and you decide to accept their offer before hearing from A, you're committed, and you need to immediately contact A and withdraw your application.   It's not appropriate to accept B while planning to back out if A later says yes.  Doing that would burn your bridges with people at B (and anyone who they talk to), and it could even be cause for A to rescind your acceptance, leaving you with nothing.