As said above, any kind of swap is "possible". Some of things I would be wary of are:
1) Bell-housing pattern and depth. Most likely you will have to use the Ford flywheel and pressure-plate. You may end up using a Mazda friction disc because of the splines needed. Does the Mazda trans need a pilot bearing in the crank? The lineal relations of the trans shaft, disc location, and throw-out bearing all need to be checked. The throw-out bearing and fork must fit over the snout of the trans; those may need to be Ford, Mazda, or something other to make this all come together. Custom fab or machining of some parts may make this quicker/easier than chasing down standard parts from other applications that will work; but probably will be more expensive. The Ford starter motor probably mounts on the bell-housing, is that going to work OK with the Mazda 5-speed bell-housing? Does the Ford bell-housing for a manual trans separate from the (Ford) trans, so it could be adapted to the Mazda 5-speed?
2) Check how the steering and suspension parts clear the oil pans. If the sump on one engine is at the opposite end from the other, then some real trickery may be needed. Sometimes a "tunnel" (tube welded in) is needed in the pan for steering rods to pass through!
3) Motor mounts. If they are different on the two truck frames, then some custom fab/welding will probably be necessary.
4) Width of the V-6 on top. Will the heads, and accessories like alternator, PS, A/C, etc clear the shock towers, frame, brake-booster, wiper motor, etc? How about the firewall, will the back of the V-6 clear that if the trans is left in the original place in the Mazda? You really would want to leave the trans in the same place, to avoid having to change shift linkage and drive-shaft length.
5) Or, if the 5-speed goes into the Ford, you probably need to fuss with the drive-shaft (length and front yoke) and provide all the clutch and shift operating stuff.
6) Is there room to fit a radiator big enough to cool the Ford into the Mazda? Custom radiators are readily available, but not cheap.
7) I assume you have no emissions testing/requirements, and are free to do (and pay) for whatever exhaust mods are needed. I'll also assume a clutch and flywheel is readily available for that Ford engine. Even if that is the case, be sure the crank is configured to take a pilot bearing (if needed).
8) Check clearance from the top of engine to hood, once you figure out what the engine mounts need to be.
9) Electrically it would be much easier to put the 5-speed in the Ford, but mechanically (clutch and shift linkage) maybe the other way around. Which truck do you like better over-all, and which is in better condition?