Dogs are scavengers by nature, and many have the annoying habit of raiding trash cans. They're acting out their innate curiosity and drive to look around everywhere for good stuff to eat, but it's a behavior you'll want to eliminate. While problems are most prevalent in the kitchen, where food is most often disposed of, you'll of course need to prevent your dog from getting into the bathroom garbage too.
Keep the bathroom door closed. Preventing entry into the bathroom altogether is undoubtedly the most effective way of keeping your dog out of the room's trash can.
Teach your dog not to enter the bathroom if you don't want to keep the door closed at all times but still want to prevent entry. This only works if you don't intend to bathe your dog in the room, because you must be unwaveringly consistent about not allowing entry. Repeatedly sit your dog at the entryway, point into the bathroom and say, "No" or "Out" in a firm voice. Gently restrain her from entering when she tries. Take a break for a while, then start up the training again. This time, step into the bathroom. If your dog doesn't follow, praise her and give her a treat. If she does follow, lead her out and sit her down outside the doorway. After she sits for a minute, give her a treat. Continue training for several days. Whenever your dog goes into the bathroom, clap your hands and say, "No" firmly. Immediately lead her out of the room.
Refrain from throwing away any food, food wrappers or items with food-like scents in the bathroom trash can. These beckon to your dog, and her scavenging instincts will usually override her training.
Convey to your dog that she's not permitted in the bathroom trash can, if you allow her in the room. Clap your hands somewhat loudly and say, "No" in a firm tone. Lead her away from the garbage can immediately.
Affix an environmental deterrent product to the bathroom trash can. Various kinds are available that that blow out compressed air or make a noise when their motion sensors are triggered. After your dog gets scared a few times, she'll learn not to approach the garbage can. These aren't good options for anxious dogs, though, as they can exacerbate fears and stress. Check with your vet before deciding to use one.