Standing with good posture requires more active use of your posterior chain (hamstrings, glutes) than you're probably used to. Keeping shoulders back & "down", spine neutral, abs tight, butt tight usually fixes my posture. And don't lean on one foot or the other.
Doing exercises that work the posterior chain, such as kettlebell swings and deadlifts, can help over time.