We can use Extension:LinkAttributes to generate link with custom attributes, but it generate a caption with attributes that should not be included.
See attached images for example.
I'm tested on MediaWiki 1.39.4, PHP 8.1.20 (apache2handler) and LinkAttributes.body.php (Jun 30, 2022, newest).
I make a patch of it. Please test and merge it.
Patch:
Before (bugged):
After (fixed):