It actually depends on the pokémon, anonymous. Some are more open to affection (petting, hugging, kissing, and so forth), and others are not. Always be aware of a pokémon’s body language as you approach and engage with them. If they start to back away from you, do not attempt to shower them with affection. If they squirm and protest you touching them, do not continue to touch them. If they attempt to attack you at any point, back away and give them space. Meanwhile, if they stand still and allow you to touch them or if they come to you, then chances are good you may show them affection (although keep in mind that this may not be recommended for all species—such as skarmory, for example).
Moreover, be aware that certain forms of affection to some pokémon are not actually good ideas for other pokémon. For example, while hugging is perfectly fine for a humanoid pokémon such as a jynx, hugging a feline pokémon puts them on edge, as you’re essentially binding them and preventing them from defending yourself. If you shower your pokémon with affection, be sure to do it in ways that don’t make them feel trapped or threatened. Give them the ability to defend themselves, and they’ll be more at ease and receptive to affection.
And of course, never shower a wild pokémon with affection until you establish a rapport with them. No, not even if they come to you. If you’ve spent an abundance of time with them to the point where they trust you, then perhaps it’s fine. However, if you’ve just met them, and they come to you and look like they want affection, there is a very, very good chance that it’s a trap in which that pokémon is seconds away from executing Draining Kiss.
(Nothing is more rewarding than befriending an entire clefairy colony and getting them to hug you … but also, nothing is more humiliating than stumbling across an entire clefairy colony and having them respond by giving you forty Metronome-induced Draining Kisses at the same time.)