Is there a way in WordPress to convert images to WebP without a plugin?

if GD is enabled you can use PHP

$path="YOUR_PATH_TO_IMAGES";
$pngFile="name.png";
$webpFile="name.webp";

$image = imagecreatefrompng($path . $pngFile);
imagepalettetotruecolor($image );
imagealphablending($image , true);
imagesavealpha($image , true);
imagewebp($image , $path . $webpFile , 100);
imagedestroy($image );