The phrase "make an example" is sometimes used, when a person is harshly punished for others to see. This is done to keep other people (especially the person's peers) from doing the same thing that got that person into trouble.