(Star Trek: My guess is that such an episode, if it had any serious depth, would be vetoed in the script stage - due to being an extremely painful subject for too many viewers.)
In Scifi: Real bad people exist. Real people who need help exist. Real people who just need some time to talk out their problems with the ship's / a local counselor exist.
Real people who can't be helped don't exist, they reductively condense into one of the three classes above because society and tech are advanced enough. (Except in cases of extreme breakdowns; E.G. Voyager wasn't the only ship mostly sucked to the delta quadrant.)
The poorly written second season of Star Trek Picard had a character who was suicidal and refused treatment, then killed herself.
I think people refuse treatment in real life because the drugs don't work too well, not because they don't want to feel better, and at any rate you can't have a utopias if people choose to due horrible things to themselves or each other, you just have real life, so I think it went against the tradition of Star Trek being utopian fiction.
Star Trek alone had countless plot lines surrounding incurable medical conditions. Worf broke his spine, Picard has some kind of syndrome which will cause cognitive decline, La Forge had to settle for a visor for most of the franchise, and so forth.
Even under utopean circumstances, ethical considerations abound, as in "The Schizoid Man," an exploration of both rights for artificial life and transhumanism. Sisko's father ignored medical advice because he chose to, and in VOY's "Scientific Method" we find aliens desperate to develop lifesaving technology, even at the cost of agency for Federation staff.
I don't have an answer for you. I think you've come up with a potential plot for a very interesting Star Trek episode though.