Using needle nosed pliers, it is usually possible to bend the lamp base slightly, then turn the base in the socket.
A large eraser will work, so will a piece of crushed newspaper or a chunk of dry sponge.
Use your imagination. On occasion, when there was no broken glass I have even just pressed two fingers against the lamp base and turned it out that way. But be careful that your fingers don't slip, or you might cut them.