How do I cause a shovel with Mending to heal itself?
According to the Minecraft Enchanting wikia page:
When an item with the enchantment is held (main hand, offhand, or armor slots), XP orbs collected will repair the item at a rate of 2 durability per XP instead of adding the XP to the player's total. If multiple items have the enchantment, one will be chosen at random for each XP orb collected, and if the chosen item does not need repair, the XP will be added to the player's total as normal, rather than choosing another item to repair.
Thus, it looks like just having your Mending Shovel equipped while gaining EXP orbs will allow it to repair itself.
If you're on Bedrock and can't hold shovels in your offhand (Shield slot), there's not a great solution, but mending is still useful on your shovel. The key fact is that whatever tool you're holding gets the mending at the time you pick up the EXP orbs, NOT whatever tool you used to complete the job.
When you mine EXP granting ores, like coal, redstone, and lapis, stand at the greatest reachable distance you can and mine them with your pickaxe. Quickly switch to your shovel so that when you collect the orbs, you're holding the shovel.
If you have a mob farm, say from a skeleton spawner, you can slay the mob with the sword, and quickly switch to the shovel before collecting the orbs. If you have a fully automated EXP farm, you can simply stand at it collecting orbs while holding the shovel.
Additionally, any other activity that yields orbs works, too. Collect smelted items, breed mobs, trade with villagers while holding the shovel to collect the EXP orbs and it'll mend your shovel.
These things are a hassle, but mending is still worth it on your diamond+ shovel, IMO.