The only way to fix that is to really think about it all the way through, it has to become habit. Tying legs together with a headband or tape is good too, just to get the feeling of being really tight.
Tying legs together would have the opposite effect...holding a soft object between the feet could help.
Bottom line is that the coaches' expectations aren't high enough. From the moment a gymnast (especially a compulsory) jumps to mount the bars, their legs need to be straight, or they need to get down and start over.
I've had my legs tied together with a velco strip from the floor carpet before! I'd just say think about it your whole routine! BE TIGHT SQUEEZE! This might sound kind of weird but my coach told me I was the incredible hulk and I needed to show my muscles or something so I squeezed really tight....... It worked though! I was second on bars at State in level 5 after him telling me that. Could have been first If I squeezed my legs in my dismount but I always had problems with that lol
Using a band on my ankles always helped me keep my legs straight. It was a really thick rubber one, I think the coach cut up a tyre to make it, but it did really help.
Lots of perfect leg ups also helped me, a really fun drill was to put a squishy ball about the size of a tennis ball just above your toes and/or inbetween your knees, if you dropped them you got another ten reps as well as restarting the ones you had already done.
Tying legs together does help because it makes the gymnast aware of when they're coming apart and the difference in how it feels. Trying to hold squeeze something between your legs is another good one. My dd learned to do back handsprings with good form when a coach put some candy between her knees and told her she cold have it if she did a series of back handsprings without it coming out.