...can a bug even survive leaving the cocoon before it's been inside long enough to transform?
Short answer: no. Longer answer: metamorphosis is a strange phenomenon where your body essentially turned back into mush (not entirely, of course) of potent stem cells by self-digesting enzymes. Those cells' genes would then be reprogrammed to form different forms, some staying close to their original function (legs cells would still be legs, but longer), some will get different shape and function (mandible turns into proboscis) or even turns into something else completely (wings grow from segmental cells). In the stage where those cells are turned into mush, however, the insect chrysalis, or commonly misnamed as 'cocoon' when a true cocoon is something that woven from silk to protect the actual chrysalis-has 'chambers'. These chambers, essentially acts like molds for those mush so that it can form the organ efficiently without needing apoptosis to create separation, saving energy and provides reserve cells should something bad happens during the metamorphosis. Taking the blob out of the crysalis would definitely kill it.