The AF teaches this:
In military uniform, outdoors - salute, indoors - stand at attention.
Out of uniform, indoors or out - remove head cover, hand over heart.
There might be some different traditions, since I was briefed at an Army post that during retreat we were expected to stop the car, get out and render proper courtesies while on AF bases we stop and sit at attention in the vehicle. (If you’re in you stay in, if you’re out, stay out.) Maybe this is different as well.
What’s neat is the change to flag protocol that now allows soldiers in civilian clothes and veterans to render the hand salute (present arms) to the colors during retreat.
To hear “retreat” played over the post PA system and to then stop my car, get out, and upon hearing “to the colors” come to present arms is an honor I will always cherish.