Can I use lag bolts when mounting heavy shelf units through 2 layer drywall?
I'm necro posting this only because it's a top result in Google, but contains an important misunderstanding about how connectors such as screws and bolts are designed to work. There is some important information missing.

Imagine a 2x10 laying on the ground.
Beneath the 2x10 is some drywall.
Six large men, each 200lbs, are standing on the 2x10.
Your task is to push the 2x10 width-wise across the floor, with 1,200 pounds pressing it down into the drywall.

The six large men are the lag screws.  Torquing the bolts down presses the wood against the drywall.  That's what primarily prevents it from the sliding down the wall. Not the bending strength of the fastener, but friction between the wood and the wall, caused by the fasteners pressing the wood into the wall. 

Returning to the 2x10 on the floor image, consider if there were 8 layers of drywall on the floor, then the wood and 1200 pounds pressing the wood down.  It's easy to see that the drywall thickness doesn't matter.  What matters is the pressure of the fastener pressing the wood against the wall.