Interrupt PWM signal with transistor
You may have better results using an actual logic gate for that, such as 74AC08.
Feed the PWM into one input, the uC into the other. The output then follows the PWM while the uC signal is high, otherwise the '08 output is low. AC family has good drive capability, +/-24mA, at 0 and 5V.  

If you want a really small SMD solution, there are also 5-pin, single gate solutions such as NC7SZ08.  That one also has strong outputs, +/-32mA.

https://www.digikey.com/product-detail/en/on-semiconductor/NC7SZ08P5X/NC7SZ08P5XCT-ND/673391

Either way, add a 0.1uF cap from VCC to Gnd. For 35 cents, sometimes a simple gate makes more sense than messing with a transistor and current limit resistors and pulling the output high or low when it's inactive or adding a 2nd transistor to avoid inverting the signal.

Do you need more than a 0/5V signal?  If so, what levels?