@Tony *******
Yes that's possible with a medical certificate request to Thai immigration stating that you are scheduled for Surgery on x date and will be in recovery xx days requesting either a 30, 60 or 90 day Medical Extension of Stay.
Note that it's not guaranteed that you will be granted it as it's an elective surgery and you have the option to get the One year extension of stay as Married to Thai.
And Thai Immigration will take into consideration your Thai immigration history.