How to determine correct replacement transformer for flyback converter in commercial product
If you are 100% sure about the schematic you provide I would estimate the transformer to be a certain type of 1:4 or 1:5 job, depending on the smoothing capacitor and current drain.

If then, again you are 100% sure about the schematic not doing anything fiddly with the generated 40kHz on any other point (another winding? The incoming "+5V"?) this is an exceptional candidate for replacing with an isolated DC/DC module.

A very good reason to build this like they did is that in mass production the components may be cheap compared to a 1W5 avg / 3W peak DC/DC module.

Another very good reason is needing the resulting 40kHz wave at another point, or secretly tapping off another voltage somewhere. So you do need to make absolutely sure you don't interrupt anything but the 5V to 15V conversion.

The safest thing to do is leave the 15V regulator in place and replace the remaining circuit by a DC/DC unit that makes (one way or another) at least 18V, since we do not know the ripple requirements on the output. If it's just a gate voltage (and you can absolutely verify that it is) 100mVpp on 15V won't be much of an issue and you can go for 15V DC/DC blocks. In the latter case you may need to add an extra capacitance on the output (with or without Schottky and/or small resistor) to make the module's regulation less susceptible to the MOSFET's peak gate current.

If you have a floating bench top supply that does a nice 15V and/or 18V I strongly suggest you try it with that at a conservative current limit shortly to see if that works okay, since you can know and control the parameters with those and what happens upon a mistake with a DC/DC module is always a bit guess work.

Another thing to be very weary of is that the PIC might turn the auxiliary DC/DC off by stopping the signal and you may have to account for that in any of the possible fixes, since then it may assume its "off-ness" at other points in control loops. So certainly consider that in any further research.

As to the "laboured" square, that's possibly explained with the parallel capacitor, though I would say you'd still want some kind of a protection zener to prevent the MOSFET from getting into dangerous waters. If there is none of that at all, that is your first clue they might have not spent enough time on the DC/DC design, IMHO.