You shouldn't do this. The Polish Ministry of Foreign Affairs says:
A D-type national visa permits to enter the territory of the Republic
of Poland and to stay continuously or for several successive times in
this territory for a total duration of more than 90 days during the
period of validity of the visa, but not longer than one year.
A D-type ...
Yes, you can leave Germany for as long as you want with a youth mobility visa. However, you cannot spend more than 90 days in any 180-day period in other Schengen countries with that visa. You could exceed that limit in another Schengen country if you had another D visa from that country. Similarly, if you go to a non-Schengen country such as Canada or ...