Hi OP,
Don't despair, there most definitely is a way through this. I say this as someone who has been and is in the same position.
I'm 35 weeks pregnant and am just tapering off Sertraline for antenatal depression (AND). I had AND with my first pregnancy too (DS now 22 months), although it went undiagnosed until I presented later on with PND after a traumatic birth (assisted delivery, baby in NICU, haemorrage & blood transfusion for me).
For me, the depression is directly linked to Hyperemsis Gravidarum, which I have had until 7 months with both pregnancies. I nearly lost my job over it in first pregnancy and my contract was terminated after I recovered from my episode of PND (also treated with Sertraline). This didn't do much to help my confidence and mental health either, although with the treatment I was able to cope!
For this pregnancy, I realised as soon as the HG hit that the antenatal depression was going to strike again as one week in, I was considering terminating a much-planned pregnancy. Where I live in Switzerland, antenatal care is obstetrician-led and I brought it up with my doctor as soon as I started to feel low. I was put back on Sertraline at 6 weeks and have now just come off it.
So, all of this to say that you most certainly can overcome this. It's good that you have recognised it and are prepared to sort it out now, as antenatal depression is a big risk factor for PND.
Sertraline is safe to take in pregnancy and during BF and whilst ideally you would taper off before the birth, there is no problem in continuing for as long as you need. The baby's paediatrician will need to know, just so they can be followed, but in my case he and both my obstetrician and psychiatrist were all happy for me to continue the medication if I felt I needed to.
Realistically, there is not enough time for you to start the medicine, be treated and taper off it before the baby is born, so it's likely you'll be on it in the post-partum period too (It takes a few weeks to start working). But this is preferable to your current mental state and will safeguard you against developing PND. PND is no joke, neither for yourself, your baby, your partner nor your wider social & professional circle. If you can treat the AND now, it's more likely that you won't go on the develop PND.
If you have any further questions, feel free to ask and I will try to answer them. Oh and I'm a scientist myself (PhD chemistry), so I went down the pharmaceutical treatment route with my eyes wide open.
Good luck (and sorry for the essay!).