Hi @LaraKraft
Yes, in my view this is possible. For the law on citizenship the relevant phrase is having to have had your 'habitual residence' (gewöhnlicher Aufenthalt) for a specific period of time before being able to become a citizen. If you are registered as living in Germany (Anmeldung) and are paying into the German social security system, then your place of habitual residence is Germany.
Paragraph 12b, part 1 of the law on citizenship covers the question of time spent outside Germany. It states (via online translation):
'Habitual residence in Germany shall not be interrupted by stays abroad of up to six months'
Best,
Éanna