If not allowed for actual flights, are they allowed in special circumstances such as ferry flights (e.g. flying to a maintenance base with a borrowed engine)?
Never because it is physically impossible and a completely uncertified and untested configuration. It takes substantially less time and money to ship an engine than it would to remove an engine/install an engine/ferry an aircraft/remove an engine/install an engine. It isn't uncommon to do something like that with a borrowed spare but that spare is rarely an engine.
You have mechanical differences that would prevent it - pylons almost always have some differences based on engine type, you have different inlet cowls, fan cowls, and thrust reversers
Engine control architecture is never the same between engine manufacturers - IE: GE's use of N1 vs. RR's use of EPR to determine thrust, EEC interface with airframe systems, fire system controls and indication, thrust reverser controls and indication, engine bleed controls, no way to deal with asymmetric thrust, the list goes on
Aerodynamic differences - There are usually differences on the same airframe type with different engine types such as vanes to help control airflow across the wing - mixed configurations are untested and you don't know the result
The closest you would ever get would be with a derate of the same engine type like a CFM56-3B1 on one wing and a CFM56-3B2 on the other. The B2 would be pinned to make the same thrust as a B1.