The basic code for just the tags would be this, as I posted on GitHub:
$content = str_replace('<img ', '<amp-img ', $content);
If the image has width and height attributes then that should be enough. It seems like the WYSIWYG editor adds it in style tags instead. So you'll need a regular expression, something along these lines should work:
$regex = '#<img (.+?) style="height:([0-9]+)px; width:([0-9]+)px">#';
$replace = '<amp-img $1 height="$2" width="$3"></amp-img>';
$content = preg_replace($regex, $replace, $content);
That should be useful as a starting point, hope it helps.