Wizards have taken part in Muggle wars.
Wizards have in some cases fought in Muggle wars. Wizards fought on both sides of World War I.
The wizards of America had played their part in the Great War of 1914-1918, even if the overwhelming majority of their No-Maj compatriots were ignorant of their contribution. As there were magical factions on both sides, their efforts were not decisive, but they won many victories in preventing additional loss of life, and in defeating their magical enemies.
- 1920s Wizarding America (wizardingworld.com)
One of those wizards was Newt Scamander - he mentions this to Jacob Kowalski while they were looking for his creatures.
“JACOB
Of course I fought in the war, everyone fought in the war—you didn’t fight in the war?
NEWT
I worked mostly with dragons, Ukrainian Ironbellies—Eastern Front.”
- Fantastic Beasts and Where to Find Them (The Original Screenplay)
Additionally, in an interview, JKR hinted that Dumbledore may have contributed in some way to ending World War II by defeating Grindelwald.
OJ: Thank you. Are you implying that Dumbledore had a hand in ending the Second World War [JKR laughs] by his defeat of the Dark wizard Grindelwald -
JKR: In 1945.
OJ: - in 1945?
JKR: I may well be implying that.
OJ: Do you enjoy having stuff in the wizard world connecting with Muggle - Muggles - history?
JKR: Well, I really do, yes, because I think that's what adds to the believability of the books. I think that's one of the reasons readers can imagine themselves so readily into the wizarding world because they can see how it does interconnect with our world. So it's both secret and apparent, but we, Muggles, don't have the perception to see what's right under our noses, of course.
- Owen Jones one-on-one interview with J.K. Rowling (July 17, 2005)
Though JKR hints at the possibility of Dumbledore’s involvement, nothing is ever explicitly stated on any wizard participation in World War II, or whether participating was allowed by the wizarding laws of the time. All that is said of the British Minister of Magic in office then is that he oversaw a great period of international wizarding and Muggle conflict. Nothing is said about his, or the British wizarding community’s, specific actions during this time.
Leonard Spencer-Moon
1939 - 1948
A sound Minister who rose through the ranks from being tea-boy in the Department of Magical Accidents and Catastrophes. Oversaw a great period of international wizarding and Muggle conflict. Enjoyed a good working relationship with Winston Churchill.
Though details on possible wizarding involvement in World War II are scarce, wizards have been explicitly stated to have participated in various other Muggle wars.
However, this is often forbidden.
Though they have been known to take part in Muggle wars, wizards are generally forbidden from doing so by their laws. The most important wizarding law, the International Statute of Secrecy, forbids wizards from revealing the existence of magic to Muggles. Involving themselves in Muggle wars and using magic in any way risks a breach of the Statute of Secrecy if Muggles should not, which is why involvement is generally forbidden. While wizards were involved in World War I, the British Minister of Magic had forbidden the wizarding community in Britain from getting involved in it.
Archer Evermonde
1912 - 1923
In post during the Muggle First World War, Evermonde passed emergency legislation forbidding witches and wizards to get involved, lest they risk mass infractions of the International Statute of Secrecy. Thousands defied him, aiding Muggles where they could.
- Ministers for Magic (wizardingworld.com)
Whether wizards would participate in the American Revolution was heavily debated among the American wizarding community. The President of MACUSA decided that they would not take part, but many American wizards did anyway.
It was there that President Elizabeth McGilliguddy presided over the infamous ‘Country or Kind?’ debate of 1777. Thousands of witches and wizards from all over America descended upon MACUSA to attend this extraordinary meeting, for which the Great Meeting Chamber had to be magically enlarged. The issue for discussion was: did the magical community owe their highest allegiance to the country in which they had made their homes, or to the global underground wizarding community? Were they morally obliged to join American No-Majs in their fight for liberation from the British Muggles? Or was this, simply put, not their fight?
The arguments for and against intervention were protracted and the fight became vicious. Pro-interventionists argued that they might be able to save lives; anti-interventionists that wizards risked their own security by revealing themselves in battle. Messengers were sent to the Ministry of Magic in London to ask whether they intended to fight. A four-word message returned: ‘Sitting this one out.’ McGilliguddy’s famous response was even shorter: ‘Mind you do.’ While officially the American witches and wizards did not engage in battle, unofficially there were many instances of intervention to protect No-Maj neighbours and the wizarding community celebrated Independence Day along with the rest of American society – although not necessarily alongside them.
- The Magical Congress of the United States of America (MACUSA) (wizardingworld.com)
In one particular case, the British Minister of Magic was herself thought to have illegally meddled in a Muggle war.
Evangeline Orpington
1849 - 1855
A good friend of Queen Victoria’s, who never realised she was a witch, let alone Minister for Magic. Orpington is believed to have intervened magically (and illegally) in the Crimean War.
- Ministers for Magic (wizardingworld.com)
Wizards have been told not to involve themselves in Muggle wars, but several throughout history have done so despite that.