It is often said that liberty comes at a price.

For Willian Barboza, it was speeding in the Village of Liberty in upstate New York that carried a hefty cost. But when Mr. Barboza expressed his frustration by sending a profanity-laced message when he mailed in the payment for his traffic ticket, the cost would grow to include his own personal liberty — at least for a few hours.

In a pique of anger, Mr. Barboza, 22, crossed out the town’s name, “Liberty,” and replaced it with one he thought more appropriate: “Tyranny.” He then added a vulgar little note that made it clear what he thought of the town.

Upon receiving the missive, Justice Brian P. Rourke informed Mr. Barboza that his payment had been rejected and that he would be ordered to appear in court in Liberty, two hours from his home in Connecticut.

At the hearing, on Oct. 18, 2012, Mr. Barboza received a lecture from the judge about using foul language, according to court documents, before being arrested, charged with “aggravated harassment” and handcuffed to a bench in the police station.