It's more of the issue of context here, but it's more appropriate performing changes in restrooms where there's more expectations of privacy than open public. However, here's the breakdown.
* On the Street: As long as you don't cross the "indecent exposure" laws, you should be OK if you don't mind the potential embarrassment with the act. Undergarments are generally a no-go unless you can keep things covered (keeping your shirt & pants on would be required) OR get into a more private location (like a restroom).
Shedding layers (like removing a sweater to reveal a T-shirt) is generally acceptable, although it may be personally awkward carrying the removed clothes with you until reach your home or vehicle... The common parallel is removing your coat when the weather warms up.
* In a restaurant: Shedding layers is generally permitted with discretion & consideration of fellow diners (you're not disrupting them or risking your clothing interacting with their food), but NOT changing clothes as it will offend your fellow diners.
Such action in the kitchen is generally a NO-GO, with the exception of protective clothing (aprons, chef's jacket, gloves, ect.), for health reasons.
* In a department store (like Walmart): Shedding layers is permitted, but NOT changing clothes. This is mostly on a security level, as it could be considered shoplifting (as the store staff wouldn't know if you're changing into clothes you brought with you, which would likely get flagged by the store greeters, OR originally on the sales floor)... forcing professional hospitality from the associates & management upon you in addition pulling the attention of the store's security.
Changing in the fitting room is a bit more acceptable, but would potentially raise suspicions with the clothing associates if you don't change back to your original clothes.
Changing in the restroom is acceptable... AS LONG AS EVERYTHING IS PAID FOR (& you have a receipt for it). If anything is not paid for, you're going to raise (proverbial) alarms with the staff with potential shoplifting.
As mentioned earlier, changing undergarments in ANY public place is generally a NO-GO due to public decency laws. It's best to visit a restroom to perform this change when needed.