In the second half of the 1930s, the Yugoslav government was increasingly pro-German, under the rule of Prince Regent Pavle Stojadinović, the leader of a newly established party supporting the regime, the Jugoslav Radical Union, modeled upon the Italian and German ruling parties of the time. In 1935 Stojadinović was appointed Prime Minister and left the traditional allies of Yugoslavia (Small Alliance) for the Axis. In 1939 the links with Axis were somewhat loosened when Stojadinović resigned and some main Yugoslav issues were being slowly resolved. For instance, the Croatian Banate was established by the Cvetković-Maček agreement.
Yugoslavia remained neutral during the Italian attack on Ethiopia, the German Anschluss of Austria, and the German breakup of Czechoslovakia and invasion of Poland. In 1941 Yugoslavia formally joined the Axis treaty, but after the signing of the agreement there happened great demonstrations all over Yugoslavia against it on 27 March 1941. General Simović led a coup, overthrowing the Regency and the Government.
The Axis forces attacked Yugoslavia on 6 April 1941 and defeated it within a few weeks. Capitulation was signed on 17 April. The royal family and government fled to London, and the country was dissolved.
Some parts of the country were directly annexed by the winners, the puppet Independent State of Croatia was formed, and Serbia and Montenegro was ruled by an occupation government.
The Communist Party led by Tito organized the struggle against the occupying forces, consolidating all the forces that opposed the Axis and forming the National Liberation Movement.
In Croatia, a puppet regime proclaimed the Independent State of Croatia. The flag of the state was horizontally divided red-white-blue with the symbol of the leading pro-Nazi party, Ustaša, a chequered red and white shield, in the white stripe and the letter "U" in canton in a wattle.
In Serbia, an "independent" regime led by general Nedić was established, being as independent as in neighbouring Croatia. They issued money (Serbian dinars) and postage stamps, but I found no reference to flags, though the white eagle with the ocila emblem was a frequent motif. I guess a version of the Serbian colours continued to fly.
Montenegro was nominaly declared an independent kingdom in personal union with Italy - the former Montenegrin dynasty Petrović had many connections with the Italian dynasty, and as far as I know at least in the first days of the war the Montenegrin tricolour was used. They also issued postage stamps, but continued to use the former Yugoslav currency.
Macedonia was annexed by Bulgaria and the Bulgarian flag was used there.
Slovenia was annexed directly to the Third Reich, and as much as I know there was no separate flag, though there were postage stamps and money with the arms of Provinz Leibach (Province of Ljubljana) with an eagle bearing checkered crescent on breasts.
Bosnia and Herzegovina was totally incorporated into the Independent State of Croatia, while other parts of former Yugoslavia were joined to Hungary, Albania and Italy, where appropriate flags were used.