No, wouldn't be practical.
3.0l and 4.0l are unrelated engines.
This means you would have to swap the motor, transmission, computer and all engine wiring with it, from the Escape to the Ranger, also ignition and door keys/locks because of PATS(passive anti-theft system).
Also any 4x4 parts if so equipped.
Selling the 2003 Escape and using that money to fix the 4.0l SOHC engine or to get a lower mile used 4.0l SOHC would be better option.
Rangers use two different 4.0l engines, 1990-2000 had 4.0l OHV-160hp
2001 to 2012 had 4.0l SOHC-207hp, so you have the 4.0l SOHC in an '02
4.0l SOHC was offered first in 1997 Explorer, the '97-'04 4.0l SOHC engines had timing chain issues, the new redesigned parts can be installed to fix the problem, engine must be removed to do this.
Your description reads like that could be the problem.
If you buy a used 4.0l SOHC make sure it is '05 or newer, or has had the timing chain upgrade.