Marrying a German citizen grants you the right to obtain a residence permit. It doesn’t matter if you marry in Germany or abroad as long as the marriage is legally effective and you have your principal residence together in Germany.
You are right that marriage in Germany with Duldung can be quite complicated and risky because it could happen that authorities send you back to India during the process. That’s why it sounds like a reasonable plan to marry in India (keep in mind that your Duldung will expire immediately as soon as you enter your home country).
I’m not familiar with Indian marriage law, but as long as you get a proper certificate of marriage there shouldn’t be any problems when you get in touch with German Ausländerbehörde to apply for a residence permit. In addition there is a few other requirements you need to fulfil: You need to be older than 18 years, you need basic German skills (A1) and there mustn’t be any grounds for expulsion (for example if you commited a crime in Germany in the past). Also, if you have been deported before and got an entry ban for Germany you can’t get a residence permit. That’s also why it might be a good idea to go back to India in order to prevent deportation.