I would use Render Hooks. That way you can change the default behavior of the markdown link and image tags.
Here is an example:
I have recently set this up on a Hugo site where the image is hosted on Cloudinary, and then I use the transformations there to generate a srcset of webp images that are lazyloaded.