As per my comment, this might be a partial remembering of Sam Raimi's Army of Darkness (1992), third film of the Evil Dead franchise.

Having been accidentally transported to the Middle Ages, Ash Williams is captured by Lord Arthur's men, who suspect him of being a spy for Duke Henry, with whom Arthur is at war. He is enslaved along with the captured Henry, his shotgun and chainsaw are confiscated, and he is taken to Arthur's castle. Ash is thrown in a pit where he kills a Deadite and regains his weapons from Arthur's Wise Man. After demanding that Henry and his men be set free and killing a Deadite publicly, Ash is celebrated as a hero. He grows attracted to Sheila, the sister of one of Arthur's fallen knights.
....
Upon his return, Ash demands to be returned to his own time. However, Sheila is abducted by a flying Deadite and later transformed into one by "Evil Ash". Ash becomes determined to lead the outnumbered humans against the Army, and the people reluctantly agree. Using knowledge from textbooks in his 1973 Oldsmobile Delta 88 and enlisting the help of Duke Henry, Ash successfully leads the soldiers to victory over the Deadites, blows up "Evil Ash", saves Sheila, and brings peace between Arthur and Henry. Using a passage from the Necronomicon, the Wise Man tells him how to return to the present by giving him a potion after reciting the same phrase as earlier.
It involves laughing skeletons (the skeletons seem to be having a great time) and a lot of slapstick. I can't find a scene involving a skeleton being decapitated and their head kicked away, but honestly, it feels like a scene that would be in the film.
Skeletons being raised from their graves
Skeletons siege the castle