Is it possible to make a Laser Raycast Attachment?

I thought of this. Could you make Raycast Laser Attachments?

Sort of like this:

Give me some answers please.

A simple way my brain thought of was to first make the gun of course. But raycast constantly from the barrel of the gun (or wherever the laser is from) to wherever the mouse is pointing at in the world. Then draw a trail between those two points.