The transfer case switch is located on the transfer case. It sits on the front half of the case right above the shifter linkage. It is pretty robust and I'm not sure of a failure mode off-hand that would cause the switch itself to cause intermittent flickering of the indicator light.
My guess at your issue is the gauge cluster itself. Based on my own experience with the gauges in these trucks, the bulb sockets do not make very good contact. I would start by pulling the gauge cluster and swapping the 4x4 indicator bulb with another one you know is rock solid to see if the flickering follows the bulb.
The other option is a bad ground. The 4x4 indicator does have it's own ground wire, but it just connects to the ground junction block on the parking brake bracket. If this ground location is bad it would have other cascading effects most likely. I did a write-up a while ago on how I rigged up my light to work
here . Not sure how close this was to factory wiring, but I did attempt to make it work with factory equipment.