Your baby is protected and cushioned in a bag of water, and is very unlikely to be hurt by your DS (not to say the hitting is okay, but just to reassure you.)
I don't know your situation, but a couple things came to my mind--
1. Is your DS getting out of the house every day? Little boys have tremendous energy, and he may need to run, be around other kids, and just blow off steam.
2. He is probably freaking out about the impending sibling and the corresponding upheaval in his life, and acting violent as a symptom of that. Can you simplify his environment to make things around him more calm and peaceful (limit toys, limit screen time, have super consistent routines?) Are you spending time talking to him about what's happening and asking how he feels about it? He may just be craving attention, extra snuggles or one-on-one activities with you.
(You might be already doing these things.)
If he's hurting you and not stopping or listening, it is totally okay to gently separate yourself from him for a minute, for safety. He is old enough that you can just tell him you need to go in a different room until he can calm down enough to stop hurting you. I don't see that as a punishment, if you are gentle in your approach and make sure to talk to him about what happened after the moment has passed and he's calm.
Maybe you could get him a book about not hitting/hurting others, or just spend time talking about it a lot at times when he is calm.