Well, Bumblebee could try to escape by building a device from the scraps he finds in Megatron's place. He's a resourceful Autobot. He might be able to create a communication device to call for help or a weapon to fight his way out. He could also look for any weaknesses in Megatron's security. Maybe there's a power source that, if disrupted, would open all the doors. Bumblebee could also try to form an alliance with some of the other captives or minions in Megatron's lair who might be disgruntled and want to escape as well.
One great Bumblebee and Megatron fanfic could be about their unexpected alliance. Maybe in a universe where they have to team up against a greater threat. They start off distrusting each other but as time goes on, they learn to respect one another's skills.
Bumblebee's fate in the comics is not consistent. Sometimes he dies, but there are also instances where he escapes death and remains a vital character. It all comes down to the particular comic storyline and the creative decisions made.
In a baby bumblebee transformers fanfic, Jazz could be a great main character along with baby bumblebee. Jazz is cool and smooth, and he could teach baby bumblebee some of his slick moves. Arcee, the female Autobot, could also be a main character. She could be like an older sister figure to baby bumblebee, protecting him and showing him the ropes. And don't forget about Soundwave from the Decepticons. Soundwave's mysterious and powerful nature could add a lot of intrigue to the story as he tries to spy on baby bumblebee and the Autobots.
In a Transformers and Bumblebee crossover fanfiction, Bumblebee could lose his memory and the other Transformers have to help him regain it while also protecting him from the Decepticons who see this as an opportunity to take him out. They go on a journey through different planets and encounter various strange species along the way.