There is no clear cut yes or no answer.
When I was at the Standesamt to apply for marriage, nobody ever asked for papers concerning the legality of my partners current stay. On the other hand side, they had a valid entry stamp in their passport and the clerk might have known that citizens from the country in question do not even need a visa. Or they looked at the other first world country's passport and simply did not care. So I cannot guarantee that you will not be asked if you show a Moroccan passport with expired visa stamps or no visa stamps at all.
That said, the fact that marrying is legally possible does not mean it's easy. Germany requires you to prove that you are eligible for marriage (for example not a minor, not otherwise married, not blood-related to the other party etc). That needs documents from your home country, which you may not be able to get while you are here illegally. Since that is Moroccan paperwork, I have no idea. When you get those papers, you will need an apostille and an official translation for both, the apostille and the paperwork. Be warned, those translations cost money, because that is a private service you have to pay yourself. While marrying is comparatively cheap (depending on city or region, ~100€ - ~200€) certified translations can easily cost 1000€ or more.
The safest route would be for your partner who is in Germany legally to go to the Standesamt and get a list of documents you both need to provide to be able to get married. They don't need to say a word about the fact that you are already here. Just say you want to get information on what you need to be prepared. Then as a first step, check if attaining those documents from your home country while you are not there is feasible at all. I found this difficult and time consuming (talking about months) even while we were both able to travel freely between our two countries, with visa waiver programs and no pandemic. It might prove impossible for you right now.
If you can obtain those documents, you may still want to get a lawyer for two reasons: the lawyer is on your side, the government is not. And as silly as that may sound, both the administrative clerks in charge of marriages and the one's in charge of immigration had no clue what they were doing. They made simple mistakes that I would not have accepted from my apprentice at work. Seriously bad stuff, like putting in "197" for the year of birth in an official form. (No, my wife sitting next to me is not 1819 years old, thank you very much).
So this is not an easy process and I urge you to get professional help. As a German it took me months to herd the German bureaucracy through this process while it was all legal and perfectly prepared. If I get you right, there is nothing prepared and there's parts you don't want authorities to know. Do not stumble in there hoping for a lucky chance. Get a lawyer.