I just bought a 95 YJ and the motor has a knock. Sounds like rod bearings. The question is whether to rebuild the motor or just buy a used one. Don't have cash for whole drive train for 350 swap or crate motor.
I'm going to go against the grain and say rebuild the 2.5. With some work, they can make decent power. Look on 4bangerjp.com those guys are making 4.0-like power with these engines. Something like 180hp 200lb/ft with higher compression pistons and a more aggressive cam. I rebuilt my 2.5 and while it doesn't do much below 3000rpm, I love it.
I obviously haven't heard the knock, and don't know your financial situation or future plans for the Jeep, but if it just started and is only knocking slightly, I'd be tempted to pull the pan and check the connecting rods to see if you can find a loose one or more. If you find one, remove the cap and inspect/measure the crank. It might be possible to just install some new rod bearings and run it for a while until you can afford to do a 4.0 or V8 swap. I dealt with a motor one time that had a knock that was traced to a bad rod bearing. The crank journal measured about 0.010" under, so we polished it up and installed a 0.010" over sized bearing on that one rod. The motor ran fine for a long time.
Like Shawn said, check the oil pressure but with a mechanical gauge. My stock one showed 10psi and the mechanical gauge showed 3psi. YJ gauges are notoriously inaccurate.
Unless you have a ton of cash sitting around. I'd steer clear of a motor swap. They get spendy fast. If you want a running and driving Jeep, I'd pick up a used 2.5L plenty of folks taking them out for the 350/I6/whatever swap. Yea it doesn't make great power, but you'll be driving a lot sooner and a lot cheaper if you just stick a used motor in there.
Of course make sure that motor isn't a piece before you buy it.