Updated:

1. Tame the nearest wolf

/data modify entity @e[type=wolf,limit=1,sort=nearest] Owner set from entity @s UUID

Swap wolf for cat or parrot to tame those too.

2. Summon a tamed pet

/summon wolf ~ ~ ~ {Tags:["newpet"]}
/data modify entity @e[type=wolf,tag=newpet,limit=1] Owner set from entity @s UUID
/tag @e[tag=newpet] remove newpet

The tag makes sure only the new wolf is changed. See the tag command.

3. Find your UUID

/data get entity @s UUID

It prints four numbers like [I; 123, -456, 789, -1011], which you can paste into {Owner:[I;...]}.

4. Sit and invulnerable

/data merge entity @e[type=wolf,limit=1,sort=nearest] {Sitting:1b,Invulnerable:1b}

5. Tame horses

/summon horse ~ ~ ~ {Tame:1b}

Horses, donkeys and mules use Tame:1b. See the horse command.

6. Wolf armor and collar color

/item replace entity @n[type=wolf] armor.body with minecraft:wolf_armor

Wolf armor (1.20.5+) greatly cuts the damage your wolf takes. @n picks the nearest entity (1.21+).

/data merge entity @n[type=wolf] {CollarColor:14b}

Collar colors use numbers 0 to 15: 14 is red, 11 blue, 4 yellow and 5 lime. Handy for telling several wolves apart.

7. Pick a wolf or cat variant

/summon minecraft:wolf ~ ~ ~ {variant:"minecraft:ashen"}
/summon minecraft:cat ~ ~ ~ {variant:"minecraft:calico"}

Since Java 1.20.5, wolves have nine variants: pale, woods, ashen, black, chestnut, rusty, spotted, striped and snowy. Cat variants are tabby, black, red, siamese, british_shorthair, calico, persian, ragdoll, white, jellie and all_black. Add variant to the tamed-pet summon above to get the look you want.

Troubleshooting

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.