You can shoot a pellet gun in your backyard if your local law allows it. That said, because it doesn't have a loud noise when fired you could probably get away with target practice of keeping out pests.  Know however that a pellet gun can have an effective range of 350 yards, so you always need to know what is behind your target.