You can use a circuit like:

simulate this circuit – Schematic created using CircuitLab
where \$V_{ref}\$ is the level below GND that shifts the signal. For example, if the PWM signal is 1V amplitude, with \$V_{ref}\$ = 0.5V you get a square signal \$\pm\$0.5 V.
Of course, you can add a circuit for limiting or attenuating the output of the operational amplifier. The slew rate of this device is not too critical for the frequency of 40 k, and easily find such devices on the market.
Attention
The scheme I present is only a guideline for implementation. You must take into account the gain levels of OPAMP (adjusted with external components), or if you use a comparator, the levels of signal excursion, according to the power supply.