Back when I was a teen, my boss had an early 70s Jeep Commando 4xr with the 6 in it. He used it as a service truck and plowed snow with it. As I remember, that inline 6 barely fit under the hood, the space under that hood is pretty tight. I'd have sericeous doubt a 5.7 is going to fit. I know the modern Jeeps with a 5.7 have a lot of specialty designed parts like exhaust manifolds, and intakes to squeeze in the 5.7, and those were much larger engine compartments then a 72 Commander would be. The 4.0 inline 6 was the largest motor AMC put into the Commander. The engine compartment might be deep enough for the 5.7, but its no way near wide enough, and I believe AMC shifted the heater core towards the right side to gain enough length for the 258 & 4.0.

This is coming from a guy that has shoved a lot of big motors into small places. A 5.7 has a large foot print, both in width and length.