You can pet animals in Assassin's Creed IV Black Flag
To pet an animal, approach it, and press the interaction button ("B" on Xbox 360/Xbox One, "Circle" on PS3/PS4, "A" on Wii U)
You can not pet wild animals, so avoid the temptation of petting something that can eat you.
For a list of animals you can pet, see: