Ballet always helps me get back in line. I Zumba too, which helps, but if you choose to try Zumba or a class at a gym like boot camp (men like that better) be warned the instructors tend to lean forward! It drives me crazy. If they have dance backgrounds they usually don’t, but that’s rare. I stay back straight no matter what they do.
Yoga, as @Judi suggested, is probably your surest bet at a gym to have an instructor who does positions with the back straight. I happen to not like yoga, but so many people live it. It will help develop the muscles so it’s not tiring to sit and stand straight.
If your spine is actually curved that is a different problem, but I believe at least some of it you can probably improve with exercise. And always correcting your posture when you realize you are slouching. Stomach in, stand tall, shoulders down.