This is called a "Pigouvian tax" or "externality tax" and a common example is a tax on fuel:
"In the United States, the federal gas tax was $0.183 per gallon in 2019... The revenue goes into the federal Highway Trust Fund to pay for roadway maintenance."