Yes, and they do. German studios have produced plenty of Second World War titles over the years — one reasonably well-known example is Rush for Berlin. There is no legal barrier to a German team setting a game in 1939–45.
The complication is symbolism, not subject matter. Section 86a of the German Criminal Code restricts symbols associated with unconstitutional organisations, including the swastika, with exemptions for artistic, historical, and educational use. For a long time games were treated as entertainment products rather than art, which meant developers had to swap such imagery for fictional equivalents — the iron cross or a stylised placeholder — to ship domestically.
That has loosened. German ratings authorities moved to assess games case by case as art, and Wolfenstein: The New Order was subsequently released uncensored in Germany. So a modern German WWII game can be made and sold with authentic iconography, though many still choose to alter it for a broader market.