I have published the code I use to optimize and generate responsive images on my website as eleven_ty plugin: github.com/saneef/eleventy-plugin-img2picture. It converts all <img>s to <picture>s with responsive images. You don’t have to write shortcodes.
…in reply to @saneef
Of course, you can write data attribute,
<img data-img2picture-ignore src="..." alt="..." />, to exclude from optimization.