PWM signal very noisy at high frequencies

If there are issues with the Tone function the Nano33 it is worth a try to see of the direct generation of pwm on a pin is cleaner.

Khoi Hoang who posts on this forum as @khoih-prog has written new library for purely hardware based pwm output on the Nano33 BLE boards.

If you don't wish to use a library, the PWMOut mbed api is quite simple and easy to use.
https://os.mbed.com/docs/mbed-os/v6.15/apis/pwmout.html