Heads up, there's a typo in the example code for the "image_editor_output_format" filter ...

$formats['image/jpg'] = 'image/webp';

... should be ...

$formats['image/jpeg'] = 'image/webp';

... as "image/jpeg" is the standard mime type and WP does not use "image/jpg" by default.