There is a statement in Army regulations that sort of addresses this issue. When the US or another nation's national anthem is played as part of a ceremony, AR 600-12 says:
The U.S. and foreign national anthems will not be incorporated into any musical arrangement, composition, or medley and will be played through without repetition of any part except as required to make both words and music complete.
This regulation only applies to Army ceremonies, of course. As Nick points out, the US Code doesn't say anything about this.
Peter Ansoff