It's going to depend on the dropout width of the folding bike and the axle width you have on your 24" wheel. If they match, yes, you can have the motor re-spoked.
For instance, I believe a typical mountain bike has a 135mm rear axle and a 100mm front axle. Folders can vary on these dimensions, but mine were also 135/100. If the frame is steel, you can get away with spreading the frame a little bit, but I wouldn't do that with alloy.
If you want to analyze this more, hub motors are designed for a certain rpm based on the wheel size. When I was buying a motor for my folder, I was told to select the higher rpm version for the smaller 20" wheel, which has to turn faster to get the same speed. Based on that logic, your 24" motor may not have high enough rpm capability to go as fast in a 20" rim. However, not many folks ride folders fast. The small wheels and gearing make that hard. If you have one, you know what I mean. So you'll probably be OK.
.