I had been trying to find a way to simulate a PWM signal for a sine wave, other than using a large and cumbersome PWL file, or using a comparator between a sine signal and a sawtooth for the carrier. So I found a post in the AllAboutCircuits forum that provided a voltage-to-PWM function:
https://forum.allaboutcircuits.com/threads/ltspice-take-voltage-and-convert-to-pwm.172663/
I modified it slightly to work with a sine wave, but I found that it did not provide the expected high and low duty cycles at the limits of the sine wave. It is not clear to me why this happens, and I'd like to find a way to get this to work over a wider range of duty cycles. Here are screenshots showing the effect of a slight increase of amplitude which is more than 1.65/2.5 = 66% and 33% duty cycle.
And with a little greater amplitude - distortion:
As @Jonathan suggested, setting a maximum timestep of 100 ns works a treat. I was also able to use a 2 kHz carrier in place of 5 kHz and that also allowed up to 0% to 100% modulation. Even 1 us works, and simulation is much faster.
(edit) In the interest of completeness, here is a successful simulation at 100% modulation and 10 kHz carrier for 50 Hz: