Fundamentally, from a grammatical point of view, each paragraph has its own subject. Whenever you change to a new idea or complex of meaning, you create a new paragraph. When you narrate events, every new actor or every new action of a single actor is presented in its own paragraph.
Dialogue formatting is just based off of this priciple. Each speaker is a new actor doing (in this case, speaking) something new. So each speaker receives a new paragraph.
What confuses you in your example is that Elizabeth doesn't speak. But she clearly does something, and you can even view her groaning and body language as non-verbal communication. People do not only "speak" using words, but also using facial expressions, gestures, and other behavior.
For example:
"Excuse me, can you show me the way to the train station?"
The man pointed to the left and smiled.
"Thank you," John said and went where the man had pointed.
Clearly the man takes a turn in the conversation, so his reply is given its own paragraph, although he does not speak with words.
The events in your example can be told with switching subjects as you have done (William speaks, Elizabeth replies to what he said with a groan, and William speaks again) and formatted in three paragraphs. For this, the second formatting example is the correct one.
But you can also tell the events with a single subject and in one paragraph:
William said, “Sweetie, raising greyhounds is not easy. But it is the family business.” He paused and looked at Elizabeth. She just groaned and rubbed the back of her neck. William went on, “Of course, you don’t need to take over the family business.”
Note that there are a few changes. First, I mention that William pauses. This signifies that his turn in the conversation is not over. Also, we are not told about Elizabeth from her point of view, but we look at her from Williams eyes, that is, seeing what she does is something that William does. But for that purpose, we have to delete everything he cannot see. William does not know that Elizabeth groans "at the turn in conversation", only that she groans. We could have had William guess ("Elizabeth groaned. He guessed at the turn in conversation.").