If the term is used by someone in the British Commonwealth it means an American (citizen of the USA.)
If used by an American of Southern heritage it means someone north of the Mason-Dixon line, in other words a Northerner, especially one from a state that fought for the Union in the American Civil War.
In modern times it can be either an insult or term of endearment, depending completely upon the intentions of the speaker and the sensitivities of the recipient.
In the old days, however, it was most definitely an insult... and a hilarious one at that.
It was coined in a soldiers' verse by a British officer in 1755 and was popular (with British troops at least!) before and during the American War of Independence. In his bawdy song "Yankee Doodle" literally meant one who pulls hard on his penis, in other words a masturbator.
In a stroke of sheer genius someone on the American side recognized that the only escape from this "attack by humor" was to take it up, make it our own and sing it with pride until it acquired a NEW meaning.
The first "feather in the cap" of America's fledgling Public Relations industry.