I'd say it depends on the circuмstances and if wearing the hat is required. For example, some men in the military may have to wear a hat (in my country, a beret) while in uniform. If they wish to attend Mass in uniform or need to go to confession before training and they have no time to change, it becomes a necessity and can't be circuмvented.
I have known many military traditional Catholics. They always have taken their hats off when entering a church but replaced them as soon as leaving the church.
Obviously, though, the requirement to "Pray always" does not mean that women will always be veiled when they pray of that men will never have their heads covered. If a military man was to say a quick prayer while in battle he may not have the time to take his hat off. Or a woman who does not have a hat may wish to say a quick prayer, but not having a head covering should not keep her from doing so. I think the idea is that if it is public prayer then the saying is to be applied.