No, a 1998 Jeep Wrangler automatic transmission will almost certainly
not fit a 1997 Jeep Wrangler with a 2.5L engine. While both might be Wranglers and use automatic transmissions, there are subtle, yet critical, differences between model years and engine types that affect the transmission's design and mounting points. The bellhousing (the part that connects to the engine) is the most likely culprit for incompatibility. Even if other parts *seem* to align, the bolt patterns or input shaft diameter might be different.
Attempting to force a mismatched transmission could result in serious damage to both the transmission and the engine. It's best to find a transmission specifically designed for the 1997 Jeep Wrangler 2.5L engine.