There is no unified concept of residence for all purposes (immigration, taxes, healthcare) and no harmonization or coordination at the EU level. This means that registering in Germany or getting insurance there doesn't per se mean that you cannot be considered a resident elsewhere for some purpose. The UK authorities or the NHS won't be notified of it. In that sense, an EU national could theoretically be a resident in two EU countries, at least for some time and some purpose.
On the other hand, as soon as you move somewhere else with the intention of spending most of your time and living there permanently, you are probably not considered a resident in the UK for most purposes anymore. The relevant fact here is not so much that you would be registered in Germany and considered a resident there but simply that the center of your interests (job, main home, etc.) are materially outside the UK. It doesn't really matter what else you are doing, that Germany is in the EU, etc. if you don't live in the UK, you don't live in the UK and that's usually the relevant test for the NHS.
Incidentally, if you get German statutory insurance (Gesetzliche Krankenversicherung - but not private insurance), you will also get a European Health Insurance Card (EHIC), which you can use to get access to the NHS during a visit to the UK (even people who have no special link with UK/have never lived there can). It does cover routine maternity care but explicitly would not cover you if you go to the UK specifically to get treatment or give birth so it would not solve your problem.
I think that immigration law is somewhat different in that you wouldn't lose the right of permanent residence as an EU citizen immediately but only after two years of absence from the country. My understanding is that during those two years you should be able to return to the UK and register yourself with the NHS again, no questions asked. After that, you would need a job or some other legal basis to become a (regular) resident again.
In practice, the NHS might not notice immediately but you are supposed to let your GP know. If you can make a good case that it's temporary (e.g. you're a student or you will work on a specific project for your UK-based employer), you may be able to argue that the move is not permanent and stay registered but otherwise, you will have to leave the NHS. Apparently, there is also a special rule for people who have lived at least 10 years in the UK that lets you resume coverage if you have worked less than 5 years abroad and could provide you a bit of leeway. That's probably your best shot but apart from that, the NHS is a residence-based system and residence is determined by your material situation so it's difficult to see how your could live in Berlin and legally benefit from it without misrepresenting your situation.