Can I swap freehub bodies?
Cheap 14-34 Shimano 6spd freewheels are still being made. 

As for freehub body swapping, there are a couple things at play. One is the compatibility issues with swapping freehubs at all, and the second is issues related to hub spacing, axle spacing, and wheel dishing with making the swap in question if it is possible.

Across manufacturers, there is no real freehub swap compatibility (barring cases where two different OEMs use the same Joytech hub etc). Within manufacturers there can be some. Many Shimano hubs use the same spline pattern and dimensions at the interface between shell and freehub body, and can have freehubs interchanged. Many of the common 8/9/10 Shimano freehub bodies are very close to dimensionally the same. (One sticky point here is that they can look dimensionally identical but usually need their cone/dust seal/spacers etc to be that of the hub they came from. You should assume that's the case unless you want to play games making it work right.)

That said, there are a couple exceptions to this within Shimano (completely different shell/freehub body interfaces), and 7 speed hubs are where at least one I know of can be found. So even if both freehubs in question are Shimano, it depends on the specific hubs models.

Secondly, if both are interchangeable Shimano freehub bodies, 7-speed freehub bodies are shorter, so to get the spacing back to where you started on the MTB wheel you'll have to add spacers on the left side and then re-dish the wheel. (I recommend doing it this way, because then you get more total spoke tension. You don't get all the strength benefits of a 7-speed hub because it will still have the flange spacing of an 8-speed hub.) And then on the folder hub, you'll need a longer axle.

Also I should note that just respacing the folder's existing rear wheel to 7-speed, swapping axles if needed, and then redishing it is another possible course here.