What year is your YJ? Technically a V8 swap in the State of Utah is Illegal right now for YJ's. It is NOT illegal to own a YJ that has a V8 in it, however.
For instance, say you bought a YJ from someone in California. It is a legal swap in Cali, and if the swap was done there correctly, you could register it here in Utah and get it passed. The actual work is what is illegal in Utah. The law states that you cannot increase the cubic inches over what came in your vehicle from the factory. I would look for a donor XJ with a 4.0 and swap it's motor If I were you.