Out of curiosity, how is defined a “friendly nation”? Any country the USA isn’t at war with?
When I went to Brazil on a Rotary Youth Exchange, we were specifically instructed that we were to stand and face the appropriate flag, assuming there was an appropriate flag, for the playing of any national anthem. Singing was optional, and hand over heart / saluting / whatever elses weren’t mentioned.
I sing the Canadian anthem unless it’s a solemn occasion and the anthem is being played but not sung, and occasionally the American one, not out of any loyalty to America, but because it’s fun to sing.