I'd say something like
"I have something I need to discuss but I'm very anxious and embarrassed (maybe pause) I have some negative coping strategies or behaviours. I have distressing and invasive thoughts of harming myself and sometimes I do harm myself.".... just a few ideas that might work if the doctor is any good. If you speak slowly and guage their reaction you can "halt" at any time if they seem unsympathetic or lacking in empathy

And go onto the next doctor.....
Don't underplay your symptoms or emotional pain.... a big mistake I have made (ironically, for fear of being judged, heh

)
Or you could write down the words and give it to them, I've done that once and did get a more positive reaction than the cuttingly (for want of a "better" word

...) misunderstanding and judging experience I had with the same doctor on the previous visit
I think someone posted somewhere that we learn good judgement from our bad judgements and mistakes, so true for me

I wish you luck, I think most doctors will handle this professionally and be polite at least and try to help.... and refer you to a good therapist who you have a good chance of connecting with.
(((((((((((( jacq ))))))))))))