How can I have a light turn on when a pocket door is opened?
There are some very sophisticated kits that actually use a motion sensor on the slider.  These are very very expensive and if you have a problem down the road you are taking out a bunch of drywall.  You can go this route.

However a pantry and utility room are closed off smaller spaces.  I would just put an occupancy sensor near the door in each room.  This will turn the lights on when you open and walk in.