are you old enough to carry a gun? if not, then sneak and carry one anyway when you go out to walk. If you cant do that at all, then stay away from really close to the road where someone can grab you, and make sure to always be aware of whats going on around you. Keep your phone on you where you can easily get to it, or have 911 on speed dial. You can take self defense classes, but that takes a while to learn. The best self defense is to not be in a bad situation.
undercover cops legally do not have to tell you they are cops, but if you are out minding your own business walking your dog then there is NO reason for a undercover cop to be talking to you for any reason, so if he tries to, tell him that you can only tlk to him with other people around. If it is truly a cop, he will respect that and follow you to people.