The usual German words for "flag" are die Fahne or die Flagge, and they're used in a number of idiomatic expressions, some of which parallel those in English.
Wir mussten die Flagge streichen.
We had to strike the flag.
The phrase die Flagge streichen can be used in the literal sense of striking or taking down a flag, but is more often used figuratively to mean "to give up," as in "We had to give up." Note that the verb streichen also means "to paint," but that won't be the case here!
Lass uns doch lieber von der Fahne gehen.
But let's rather go from the flag.
That is a literal translation, but von der Fahne gehen is usually used figuratively to mean "to give up" in the sense of leaving a project, or cause, or organization.
Sie stemmten das eiserne Stadttor auf und schwenkten eine weiße Flagge.
They pried open the iron city gate and waved a white flag.
Caption 48, Märchen - Sagenhaft - Die Weiber von WeinsbergPlay Caption
This too is a literal translation, as the story is about an army surrendering, but as in English, "to wave a white flag" is also often used figuratively to mean "to give up."
Wir haben unsere Fahnen nach dem Wind gedreht.
We have changed according to the circumstances.
Literally translated, this would read "We've turned our flags to the wind," but is used figuratively to mean that one has followed popular opinion or adapted according to the circumstances. It's similar to the English expression "whichever way the wind blows" or "to see which way the wind is blowing." As in English, the phrase can also be used as a negative critique of somebody being opportunistic.
One of the more common idiomatic uses of die Fahne can sound very strange to English speakers:
Buah, hat er 'ne Fahne [Umgangssprache]? -Und wie! Cognac? -Feine Thunfischstückchen.
Ew, does he have a flag [slang, bad breath]? -And how! Cognac? -Fine little pieces of tuna fish.
Captions 52-53, Küss mich, Frosch - Frosch oder Mensch?Play Caption
Du hast ja eine tierische Fahne [umgangssprachlich].
You have a beastly flag [slang, stench of alcohol].
Ich fress' doch schon die ganze Zeit Pfefferminz.
I've been devouring peppermints the whole time.
Captions 14-15, Pastewka - Cantz fährt betrunken AutoPlay Caption
You've probably gathered that they aren't literally talking about "having a flag." The phrase eine Fahne haben means "to have bad breath" and is usually associated with the smell of alcohol. The question Hast du eine Fahne? is a way of asking somebody if they've been drinking alcohol.
Look up the words die Flagge and die Fahne on Yabla German to see them used both literally and figuratively in a real-world context.