Dear @Yakub,
Welcome to the Wefugees Community and thank you for reaching out to us.
In general, marrying in Germany is not depending on the residence permit and in theory also people holding a Duldung can marry. De facto, many people struggle to provide all the required documents for the marriage process though. We discussed a similar question here - please check this thread for more details and the link to our blog on this topic (incl. a list of the documents).
Once you managed to get married, you may apply for a residence permit according to section 28 (follow the link for the prerequisites) of the German Residence Act as spouse of a German citizen. However, please be aware that the immigration office may ask you to apply for a family reunification visa at the German embassy in Ghana before they issue a respective residence permit. You can find more information and links in this thread, for instance.
I can always recommend to contact a migration counselling office as well to get more tailored information and individual support. Let us know if you need help in finding such an office in your area.
I hope this helps and all the best,
Meike