Proverbs 17:26

Also to punish the just is not good, nor to strike princes for equity.

Cross-reference

Proverbs 17:15 condemns acquitting the guilty and condemning the righteous—directly reinforcing the injustice of punishing the upright.

Proverbs 18:5 warns against depriving the righteous of justice—echoing the same principle that punishing the upright is evil.

Genesis 18:25 shows Abraham arguing that God should not punish the righteous with the wicked—same principle that punishing the upright is unjust.

Jeremiah 37:18 shows the prophet protesting his unjust imprisonment—a direct example of a righteous man being punished.