One idea: Could you sound genuinely curious? Like, "Oh? I didn't realize your ex's family had Bad Habit in it. Who was it?" Like it's a normal conversation and you're talking about a neutral trait like red hair or something.
Another idea might be to get to the root of talking bad about someone. "MIL, I don't really want to gossip about Bob's mental illness. Can we talk about something more positive?"
A third idea would be to point out that she does this, straightforwardly. "MIL, I've noticed that whenever someone shows a bad trait, you insist it couldn't come from your line of the family. But whenever they show a good trait, you take credit for it. Do you realize you've been doing this?" Kind of like it's a bad habit, like drumming her fingers or chewing her nails, and you're helpfully pointing it out. If it's pointed out to her directly, she may catch herself before she does it again.