Yep, it's possible. Usually cell service (at least in the USA) cuts off around 2,000' AGL. Many factors involved here. I've had SMS come in at 8,000' AGL, but replying took a bit of effort. I've heard of it working much higher in rare cases.
Someone please correct me if I'm wrong, but don't iPhones route all SMS through Apple's servers? If that's the case, I'd imagine SMS messages would be more than happy to be transmitted via WiFi. I know my T-Mobile Samsung S10+ works fine on Gogo for all its functions, even phone calls. I also know that Android phones also can turn on WiFi in the background. Not sure if iPhones do this.