Privacy matters in health care and they'll keep your information as private as possible. But be honest with your doctor about what is going on especially the suicidal ideation. good luck
The same happened to me on Zoloft. It didn't help at 50mg and then started causing suicidal thoughts at 100mg. Talk to your doctor. These symptoms are common and will almost certainly fade once you're off the medication. Medication is mostly trial and error, but keep trying. It took me multiple attempts and a new psychiatrist to find the medications and dosage that have been helping me. It's important to keep up psychotherapy too if possible.
As for the custody battle, I don't know if you mean "doctor" as in an actual doctor or a psychiatrist, but if it is the latter, yes, your records can be subpoenaed. However, psychiatrists still need your written permission to follow through with the order. If you don't give permission, you might cause trouble, but if your psychiatrist knows what they're doing, they might be able to defend your right to privacy. If you must allow your records to be subpoenaed, it's not the end of the world. If your psychiatrist testifies and is qualified as an expert by one of the attorneys, the opposing attorney may ask about your depression and about suicidal thoughts, but your attorney can negate that by prompting the psychiatrist to testify that your depression does not make you a bad parent, you are not a danger to yourself or others, the suicidal thoughts were an effect of the medication, etc. Good luck with everything!
This is a common side effect of antidepressants, maybe the most common, but it affects mostly young people and usually pretty soon after starting the med. If you've been on it for awhile, it might not be a side effect of the med but a sign that the med isn't working for depression, which perhaps you've always had but didn't notice because the anxiety overwhelmed it or perhaps the intense stress of the custody battle and the divorce has brought up new issues. I would definitely talk to your psychiatrist -- your conversations are privileged under the law unless you are an immediate threat to others. Now, it's not impossible the thoughts are a side effect, especially if the drug isn't working anymore, in the sense that sometimes when that happens you can go into withdrawal, and withdrawal can have a host of problems. You're not missing doses, I hope.
Talk to your pharmacist or the manufacturer. Most side effects disappear with time - you didn't say how long you have been on this med.