How to measure energy distribution
To measure the power consumption of each motor, you'd need to measure the voltage and current, before the motor driver.

(the 3 phase power after the driver will be very hard to measure).

Both voltage and current measurements will need to be filtered to remove the 40 kHz signal, which will otherwise cause all sorts of trouble, as you correctly anticipate.

Fortunately, 40 kHz is far away from your likely sample rate of about 50 Hz. A first order RC filter with its knee at 40 Hz will attenuate the 50 kHz ripple voltage by about 30 times, which might be enough. An inductor and two capacitors will be much better.

Voltage is fairly easy to measure - as a nice low impedance source, you can build a simple filter and feed it to your ADC. You only need one voltage measurement after the 24 V power supply. The ripple in the voltage should be fairly small anyway.

Current is a bit more tricky. You could use a sense resistor in the ground wire, and an op-amp to amplify the small voltage, then the filter. At some torque settings, the current might really be a square wave at 40 kHz, it'll be hard to measure and filter. It might be an idea to filter the power line itself with one LC, just to remove some of the ripple, and then filter the sense output again before the ADC.

One last digital idea would be to sample faster than you need to, perhaps at 1 kHz, and average these in the Arduino. The aliasing will still be a problem, however if you randomise the time of the samples, you may be able to average out the 40 kHz signal, preventing it from being properly aliased into your band of interest. Some experiments here would be valuable.