I haven't had surgery. But I've been on HRT for 5 years, and have fully transitioned. I live in a fairly socially progressive place, my family does not. My family ranges from bigots to allies, but tends to lean towards bigot. My own results were losing about half of my family, but not a single friend. You can pick your friends, but not your family. I chose great friends.
I'm glad I did it. When I made my final decision, I was prepared to lose it all. My job, my family, my friends. It meant that much to me. That said, I didn't have to deal with legal problems, outside of obstructing officials. So I wasn't afraid of being legally punished.
So my advice to you is to not worry about what other people think. You can't control that, and it's minor compared to your legal problems. If they really loved you, they would understand. But the legal problems only really have one real solution. Move. Get out of there any way you can.
The only alternative is to find loopholes in your laws. If you live in a larger city, there's sure to be underground queer movements somewhere. Find them, ask them for help.
Edit: Also, now that I've had my caffeine, I also want to add a couple of things.
-
Things don't change unless people are exposed to new things by the people close to them. It's easy to make oppressive laws when it's conceived as something scary and foreign. Internal pressure is needed to change the status quo. Obviously it won't do anyone much good if they execute you, but even if you came out outside of the country, that still challenges the status quo. There's no need to be a martyr.
-
My mom was a lifelong homophobe. What changed her mind about gay people was that one of the elders on my reserve came out as gay. She'd known him for decades, and the reality was suddenly thrust upon her that queer people are normal people and not so scary as she thought. You might be surprised.