more of an artifact of how it processes data than a "Trick"
Digital cameras don't read all the data in one shot, but read it in a row by row stream(quickly)
If you google Rolling Shutter Lightning there's some good sites (don't know about the language, some sites might have language that's not appropriate for this site, so I'm not linking them) with fully detailed explanations on what's going on, the digital processing science of how the CMOS chips handle the data, memory read patterns ect.
But simply put the camera takes a over all light measurement without the lightning, starts to process the image, gets part way done when the lightning flashes (overexposing one or more rows of CMOS image cells) , lightning finishes, as the camera finishes processing the rest of the data, giving you the beam effect.
If the camera was rotated 90 deg you would end up with a horizontal beam vs a vertical beam