Using a 4wd ecu in a 2wd car: Yes, if you change the wires from the TPS and use a 4wd TPS. You cannot use closed loop unless you connect a Oxygen sensor.
The chip also needs to be setup for a 2wd car and the knock sensor must be taken out of the setup. Same applies to closed loop, it must be taken out or a sensor must be added.
Using a 2wd ecu on a 4wd is also possible, again you have to change the wires on the TPS and use a 2wd TPS. And again the chip must be mapped for a 4wd engine.