Don't start punishing your dog when it barks - that's the worst thing you can do because it creates anxiety and makes everything worse. A German Shepherd at that hour probably has a combo of factors going on: the light drops, the senses sharpen, maybe it's actually hearing noises you don't notice (crickets in gardens, cars coming, other things). But there's an element a lot of people underestimate: dusk destabilizes the dog because the world changes visibility, and a working breed like yours interprets this as "I need to stay alert, something could enter my territory".
Try blocking the view from the window during that critical hour with an opaque curtain or a screen - it's not a punishment, it's removing the trigger. When it can't see what sets it off, it stops having a reason to alert. In the meantime, keep it mentally occupied before the sun goes down: scent work in the house, interactive puzzles, something that makes it focus on a task. Also change the "meaning" of that time slot from "alert moment" to "playtime or reward time".
If even this doesn't work, it might be worth consulting a trainer, because sometimes there's deeper territorial anxiety or frustration tied to something happening specifically outside. But start with these steps, it's the most logical way to figure out what really triggers it.