I did this project last year, I'm a mechanical designer and in this video you can find a whole tutorial on how I made this LightSaber Retractable. https://youtu.be/jiIGRBxh4nA?si=HpKv8rqjqA0J1Pxh
I wanted to make the replica of Luke Skywalker, I live in Venezuela and my resources were a little limited to put a light bulb on it, like this which I solved with PLA Glowing material. And the handle of the saber is made of PLA Silk, thus saving me from having to paint it.