When a person or corporation is adjudged guilty of usurping, intruding into, or unlawfully holding or exercising any office, franchise, or privilege, the court shall render judgment excluding the defendant from the office, franchise, or privilege and may also impose a fine of not more than $3,000.