How to create a resource if a collected virtual resource returns empty with Puppet?

I have a Puppet profile which collects some virtual resources. It typically collects 3-4 resources, that part works well.

For some servers, it returns empty. Again, this works well.

I can do the following:

MyResource <| |> ->
file { '/etc/myfile.conf':
  ensure: 'present',
  content: 'some conf',
}

This code, if it collects at least one resource, will create the file “myfile.conf”. If it collects zero resources, it will not create the file.

Now I would like to do the opposite: create a file if it collects zero resources. Is it possible? I can do a hack like the following, but that feels wrong:

file { '/etc/myfile.conf':
  ensure: 'present',
  content: 'some conf',
} ->
MyResource <| |> ->
exec { 'badhack':
  command: 'rm /etc/myfile.conf'
}

This creates the file, and if it finds at least one resource, it will delete the file.

I feel like it should be possible while respecting the declarative spirit of Puppet, but I’m not sure. Is there some syntactic sugar I’m missing here?