thank you for contacting the wefugee community. Like @Meike already mentioned, there is no rule stating you have to work in germany. You find the rules of naturalization also here
https://www.gesetze-im-internet.de/stag/BJNR005830913.html (sorry I could not find an english version).
If you want to be 110% sure you can turn to the local authority that is responsible for naturalization in your community and ask the staff there. Usually this is the registration office / community office.
Please feel free to contact me again. My name is Ruth and I am a professional refugee advisor. In case you need a confidential consultation you can write me via the app ‘mbeon’, which provides advice for adult immigrants in Germany. Download the app at Google Play or App Store and get in touch with me or 160 other migration advisors. It's free of charge, anonymous, data secure and you can get advice in 15 different languages. Find more information here: www.mbeon.de.