Very doubtful, try check the part number, if they match (harness connectors) they might be able to swap, but will surely need reflashing. Usually however older computers never work for newer models or can't be updated to factory specs needed for other engine.
If both engines are SOHC or DOHC there is a small chance it will work. My advice it to use the exact correct part to avoid problems.
Looking for a Used Forester in your area?
CarGurus has 1,253 nationwide Forester listings starting at $2,900.
Search Subaru Forester Questions
Subaru Forester Experts
Find great deals from top-rated dealersSearch
Related Models For Sale