1. don't panic
It's likely that someone hearing voices is in a fragile, vulnerable place. Panicking about what to do could make them feel stressed and anxious, which might amplify the experience. When I've been hearing voices, I can often almost see the gears in people's heads going into overdrive.
The vast majority of people who hear voices are just struggling with what they're hearing, and are not a danger to anyone else. If you're worrying about what you can do, then ask. You don't need all the answers. It's just important to stay calm to not add to the fear and anxiety they may already be feeling.
2. sit with them
The simplest action, and often the most genuinely useful, is just sitting and being there. When you hear voices you feel out of touch with reality. It can be an intense and scary experience. You're not always sure what's real and what isn't. It creates a surge of fear and anxiety.
I find that having someone sit with me helps to ground me. Knowing the person next to me is real, and I can talk to them if I need to, is a huge source of comfort. It's a really simple act that can make a huge difference.
About literally anything - the weather, or the surroundings. Tell them your life story. It can be as mundane or as interesting as you'd like. The idea is to help the person focus on what you're saying, rather than the voices. Hearing a voice can help the person you're with concentrate on something that is real and tangible. The more relaxed and chilled out you can be, the better.