during the Hitler era, the Lutherans in Germany did not refuse communion to those who belonged to the Nazi party.
The Catholic Church in Germany excommunicated the Nazis, and excommunicates cannot receive Holy Communion.
Another instance was when St. Ambrose of Milan (346-395 A.D.) excommunicated the Christian Roman emperor Thedosius I, who, out of excessive zeal and to make an example, ordered the massacre of 7,000 innocent spectators in an amphitheater of barbaric gladiatorial games in Thessalonica (390 A.D). St. Ambrose wrote him:
It grieves me that you, who were an example of singular piety, who exercised consummate clemency, who would not suffer individual offenders to be placed in jeopardy, should not mourn over the destruction of so many innocent persons … I dare not offer the Sacrifice if you determine to attend.
After 8 months of public penance, Theodosius was readmitted to the Church. St. Ambrose's said at his funeral 4 years later:
I loved him because, divesting himself of his regal state, he wept publicly for his sins and asked for pardon with groans and tears. I loved him because, Emperor as he was, he was not ashamed to do the public penance from which many of low degree shrink, and because he deplored his sin every day he lived.
—Rengers & Bunson, 35 Doctors of the Church, ch. 7 St. Ambrose
Saint Ambrose barring Theodosius from Milan Cathedral: