thank you for sharing your question. There is no punishment for impregnating another woman while being married. However if he's still trying to get a family visa and his wife separates from him within the first 3 years after marriage, he'll not be able to apply for a permit as a spouse. If the mother of the unborn child is German and she is willing to share custody, it will be possible to apply for a permit to stay in Germany as the father of a German child. Anyway, since your friend is still fighting a court case, it might be best to consult his lawyer regarding that matter.
I hope my answers were helpful and I would be very happy if you would contact me again with further questions. I'm a consultant with mbeon and I‘ll be glad to help you over a longer period of time. Mbeon is an online advice for migrants via the mbeon app, which you can install on your smartphone for free. Download it from App Store or Google Play Store. You can find me in the mbeon app and get confidential individual advice in a secure virtual space without other people reading our conversation. Further information: www.mbeon.de.