Hanging was a form of capital punishment by which an individual was suspended in the air by a rope, usually tied at one end into a knot called a "noose".
To effect a hanging, the rope was affixed to a tree, beam or other fixed point, and the noose was tightened around the victim's neck. The victim was then pulled up or a support was dropped from underneath him until his entire body weight was being borne by his neck. Death would subsequently result from strangulation or the neck's inability to bear the weight of the victim.
In 2267, on stardate 2124.5, Trelane held a mock trial of Captain James T. Kirk on Gothos where he issued the verdict that Kirk would "hang by the neck until" he was "dead, dead, dead." (TOS: "The Squire of Gothos")
In 2369, Constable Odo faced chages of murder and he was hunted down by an angry mob who cornered him in his security office. Commander Benjamin Sisko tried to calm the situation and asked what the angry people wanted to do with Odo. Zayra answered, "He's right. How do you get a rope around the neck of a shapeshifter?" (DS9: "A Man Alone")
In 2374, on stardate 51096.2, during the Dominion occupation of Deep Space 9, Vedek Yassim organized a demonstration on the Promenade. Yassim appeared on the upper promenade level and exclaimed "Evil must be opposed" before she stepped off the second level with a rope around her neck, hanging herself. (DS9: "Rocks and Shoals")
In 2375, on stardate 52081.2, after the crew of USS Voyager voluntarily chose to disobey Captain Kathryn Janeway's orders, Janeway remarked that they could all be "hanged for mutiny," a reference to the ancient naval custom of hanging mutineers. (VOY: "Night")
In the DS9 book series Star Trek: Deep Space Nine - Millennium, Quark is hung on the Promenade for the crime of being a Ferengi, amongst others, by a group of angry Cardassian soldiers on the Day of Withdrawal from Terok Nor. He was subsequently rescued by another group of Cardassians.