Do you mind telling us anything about the hardware you are using?
Maybe a esp82xx with software pwm?
Note that this is a software PWM, so there can be some flickering during periods of high WiFi activity. Hardware PWMs like the one on the ESP32 (see ESP32 LEDC Output) are preferred.
Or by chance a esp32 with hardware pwm?
And what about your yaml? How does that look like? What frequencies are you using? So many questions…