Change the name of uploaded file based on content type and entity id
You might be able to do this with hook_ENTITY_TYPE_update().  Take a look at the D8 version of the upload_replace module code for an example of changing filenames.