ScriptedImporter provided in the repro case is not setting up a dependency to the prefab being referenced. A dependency must be registered an prefab and this can be done using https://docs.unity3d.com/6000.3/Documentation/ScriptReference/AssetImporters.AssetImportContext.DependsOnArtifact.html.
In the provided repro, the artifact dependency can be setup like this:
////
// Check if reference is set
if (!object.ReferenceEquals(prefab, null))
{
int instanceID = prefab.GetEntityId();
// Retrieve the GUID associated with that InstanceID
if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(instanceID, out string guidString, out long localId))
{
if (GUID.TryParse(guidString, out GUID artifactGuid))
{
// Register artifact dependency to asset referenced.
ctx.DependsOnArtifact(artifactGuid);
}
}
}
////