My 2015 Nissan Pathfinder has a switch for 2WD, AWD (auto), and 4WD Lock.
Do I save gas by keeping it in 2WD? Or it doesn't matter because it's still the same drivetrain and it simply doesn't apply power to the rear wheels?
It's unlikely that 2WD will save you a lot more fuel than AWD but it will save you more than zero. 2WD will definitely save you fuel over the 4WD Lock setting.
The reality is that, no matter what setting you use, the engine still has to move the same mass of metal down the road. I.e., maximum efficiency is bounded. That said, in 2WD mode, you are avoiding some parasitic drag that would be caused by the differential and other mechanicals associated with the other pair of wheels in AWD mode. It's hard to say exactly how much additional drag will be induced by the AWD implementation since it will be situation dependent but it is more than zero.
Both of these are much more fuel efficient than 4WD Lock mode. Most owners manuals that I've seen also recommends the lock mode for low speeds as well.
Given all that, it is easy to measure the instantaneous fuel usage in a modern car. A decent OBD reader (it plugs into the OBD port under your steering wheel) will allow you to display the fuel injected per second. If you really want to know specifics for your vehicle, try a stretch of road where you do repeated test runs in the different modes. Bonus points if you bring a data recording co-driver with you rather than having to grope for the reader while bombing down the back roads....