The original Yankee Doodle song was written by an Englishman as a mockery of the Americans.
The American Army adopted the song and turned it into a call of togetherness. They marched to the song being played on their fife and drum.
Legend has it that an entire British landing party was scared off by two young girls playing it on their own fife and drum. The landing party, it is said, thought the American army was nearby.
And what's this business of "stuck a feather in his hat and called it macaroni?" "Macaroni" was a fancy ("dandy") style of Italian dress widely imitated in England at the time.
So by just sticking a feather in his cap and calling himself a "Macaroni" (a "dandy"), Yankee Doodle was proudly proclaiming himself to be a country bumpkin, because that was how the English regarded most colonials at that time.
So at that time saying something was "macaroni" was the same as saying it was "cool" "neato" "nifty" or "groovy" depending on your age.
Yankee Doodle was the very first song recorded on a record. You may see various lyrics to the song - here is one version: