PETG is food safe. However! Because FDM is full of gaps, cracks, and voids, NEVER use it to store food that can spoil. Food bits can get trapped in these voids and present a persistent risk for foodbourne illness.
Granulated sugar would be fine if it’s kept very dry, however do note that said voids will not make an airtight container. So I wouldn’t even use it for stuff affected by humidity or oxygen.
If anything I’d almost suggest clearing the inside with a food safe platinum silicone, which should solve most of these issues.
Hope you didn’t click that link. You probably downloaded a malicious payload.