Check the u-joints on the front driveshaft - you may have lost a bolt on the saddle strap which holds the u-joint of the front driveshaft to the transfer case output. When you engage 4 wheel drive, the output shaft starts spinning and would throw the driveshaft all over the place if it's loose, making one heck of a banging sound. You wouldn't feel it in 2 wheel drive if its only the front driveshaft.
89' YJ - 4.2 - NV4500 - NP231w/sye - 1" Body Lift - 2 1/2" Rancho Suspension Lift - 31" Firestone MTR - AR Outlaw II - Tomken Bumpers F & R - Warn 8000 front - Warn 6000 rec. mount rear - FlowFit Seats - Tom Woods Rear & Custom 2" front driveshafts