A 15-year-old boy has been charged with allegedly murdering a 22-year-old man “over a hat”, a court has heard.