You can erase images from a custom module. This is only tested in Drupal 8.9. First let me explain the image process so you can better understand if this solution is the right fit for you. An fid is stored in the column of your custom table you use to reference your image. It is the primary key in a table called file_managed that stores the image information. The image is stored in the "web/sites/default/files" folder. This might be different depending on your Drupal installation. table_usage stores the usages of the image on the site. When you erase an image you need to erase the row with your images fid from all three tables file_managed, file_usage and your table. Then of course unlink your image.
/**
* Removes an image.
*
* @param $fid
* @return boolean
*/
public function removeImage($fid) {
if ( empty($fid) || !preg_match('/^[0-9]+$/', trim($fid)) ) return FALSE;
// Im assigning the $this->database property an instance of Connection
$result = $this->database->query("SELECT uri FROM {file_managed} where fid=:fid", [':fid' => $fid])->fetchCol();
$absolute_path = \Drupal::service('file_system')->realpath($result[0]);
if(isset($absolute_path)) unlink($absolute_path);
//var_dump($absolute_path); exit();
$this->database->delete('file_managed')
->condition('fid', $fid)
->execute();
$this->database->delete('file_usage')
->condition('fid', $fid)
->execute();
return true;
}