Welcome to the Wefugees Community and thank you for your question.
As far as I know and as also mentioned in this thread, as father of a child with a residence permit in Germany there is no legal guarantee that you get a resident permit to take care of your child (“Aufenthaltserlaubnis zur Ausübung der Personensorge”). Instead it will be at the discretion of the immigration office if they will issue a respective residence permit.
In any case it will be important that you are officially registered as the father (acknowledging of the fatherhood) and that you share the custody. As the mother of your child is married, her husband will be registered automatically as father. The situation is definitely more complex and I would recommend you to seek individual consulting, for example via the mbeon-App, in a migration counseling office or seeing a lawyer.
All the best,