They can also grab ammo on their own if they are carrying the right weapons. If you don't want them wasting ammo, make them trade it back to you. If you give them another weapon and have them equip it - they'll need consume ammo to keep using. Every human companion has a default weapon that they have unlimited ammo for. For example, having a Pipe weapon (with ammo that can be found easily) a laser weapon (with less abundant ammo sources) and a sniper rifle (rare ammo) lets you fall back to other options.
Increase you ability to find ammo elsewhere with the Scrounger Perk.Besides traders, you can only find ammo off enemy corpses, in Ammo Crates/Big Chests, and statically placed in the world.