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 25, Märchen, Sagenhaft: Die Weiber von Weinsberg
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 eine Fahne? -Und wie! Cognac? -Feine Thunfischstückchen.
Ew, does he have a flag? -And how! Cognac? -Fine little pieces of tuna fish.
Captions 52-53, Küss mich, Frosch: Frosch oder Mensch?
Scheiße, du hast ja eine tierische Fahne.
Crap, you have a beastly flag.
Caption 14, Pastewka: Cantz fährt betrunken Auto
Du hast ja noch eine tierische Fahne. -Ich fresse doch schon die ganze Zeit Pfefferminz.
You still have a beastly flag. -But I've been devouring peppermints the whole time.
Caption 37, Pastewka: Verkehrsrowdy Bastian Pastewka
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.