“And he hanged the king of Ai on a tree.” From Deuteronomy 21:22-23. In the Old Testament, the person was killed then the dead body was put on a tree (or a stake; the Hebrew can mean either) for display.
“raised over it a great heap of stones.” This would serve as a warning, and bring to mind what happened to people who defied Yahweh. Israel had done the same thing to Achan, who sinned against Yahweh and caused the death of 36 men (Josh. 7:26).