This is the cocoon of a parasitic wasp (Microplitis plutellae) that attacks and kills diamondback moth larvae. This wasp will lay an egg inside the caterpillar, where the wasp larva feeds before emerging from the mature caterpillar to spin its cocoon, killing the caterpillar in the process.
For more information on parasitic wasps and attracting beneficial insects, see:
HGIC 2820, Natural Enemies: Predators and Parasitoids
HGIC Beneficial Garden Insects