Yes.
Technically, according to Monster Manual p.9, "Challenge":
- You gain XP for defeating the monster. There's no distinction here for weapon of choice. Throwing acid is just as legitimate as throwing daggers, say. Pushing the enemy into a conveniently placed vat of acid is equally valid. It's his own fault for building an uncovered vat of acid in his lair.
- Monsters with a challenge rating of 0 are worth no XP if they have no effective attacks and pose no danger, but 10 XP if they do have effective attacks.
However, this particular question suggests you may have one of two particular exploits in mind, and I'd like to point out that both have been discussed before.
What if I tie a hundred vials together...
In Inventiveness vs. breaking the game; How do I encourage one, without enabling the other?, a player fills a net with hundreds of vials, ties it to a rope, and swings it at the enemy as an improvised melee weapon:
I thought the idea was impressive, and didn't think it would actually be a huge problem for an enemy... until it was. He ended up tossing something like 200 vials in the net, and managed to kill something a full 10 CR higher than the group, on his first turn.
This won't work in D&D 5th edition, because by the rules in the Player's Handbook you have to throw one vial at a time. There aren't any rules that say you can tie a hundred vials together and throw them with a single attack roll, and even if the DM lets you do that, there's no rule that says you can just multiply the damage value by the number of vials. A creature only has so much surface area.
Bear in mind that acid in D&D 5e is 25gp per vial. Suppose you want to kill a young red dragon, which has 178 hit points. On average, that's 26 vials of acid, or 650 gp worth at bare minimum. Even if you somehow threw them all at once and did 26 vials worth of damage, the dragon's AC is 18. You might miss. Did you being a backup sack of acid? You're spending maybe a quarter of the dragon's treasure hoard per attempt. The party needs to do a cost/benefit analysis up-front before attempting this.
Well of toads
The other fun exploit I remember from D&D third edition is the "well of toads". Buy enough toads to fill a well, throw them in, set the well on fire and claim the XP.
You can't do this in D&D 5e—not with toads, because they're 0 XP.
Technically, you can do it with lizards or weasels or something that has 2 hp and deals 1 damage per hit.
However, the DM shouldn't allow you to gain XP for defeating something that's not a challenge. Caged weasels can't harm you, but the real challenge might be getting them into the well. Uncaged weasels, if you have enough of them at a time to matter, would probably constitute a swarm of weasels, and that'd count as a single swarm creature, with a higher challenge rating, and a valid threat for XP purposes.