What's the best way to change markdown output in Grav?

For example ![](someimage.jpg) will produce <img src="route/someimage.jpg"></img>, but what if I want for example to change src to data-src like this
<img data-src="route/someimage.jpg"></img>?

I could use regex and the onPageContentRaw hook, but is there a better way? Is there a template system but for markdown output?

No, Markdown is a very strict and simple syntax. The parser Grav uses, Parsedown, demonstrates this well. The easiest, and most likely most performant, way of doing this is with a simple regular expression. The other way is DOM-manipulation, which is very slow in comparison to regex.