In a beehive, a lazy bee getting fat off the work of others pretty much sums up the drones. So within limits this already happens.
Worker bees go through all the various aspects of work through their lives, tending the queen, tending brood, making comb, cleaning the hive, with the final job being foraging. The entire hive is governed by a complex interplay of pheromones emitted and responded to by every kind of bee in different ways. A worker bee that fails to operate correctly in the face of the appropriate signals is simply broken. One would assume that there are always some busted bees for one reason or another. Some are sick, some injured, some mutants. A bee emitting the right pheromones whilst in the hive will be ignored, the wrong ones and it may be killed and ejected.
What is curious about hives is that it is possible to replace a queen with another from a totally different lineage. Beekeepers will do this if a queen is weak or the hive is particularly belligerent. The workers will tend the new queen happily. Given this is hard to achieve naturally there has probably been no pressure to evolve a protection mechanism.
If a queen is weak or dying she will cease emitting enough queen present pheromone, and in areas of the hive where the levels are too low workers will start building queen cells and begin the process of succession.
A hive is more like a single organism. Even the idea that the queen rules the hive doesn’t really capture the interplay. She is just a fertile female that is manufactured to make eggs. But she is a key player in the behavioural engine driven by pheromone levels.