The output shaft sensor on your car is what is known as a Hall Effect sensor in that it uses a magnetic field to detect a reference point on a rotating object. In this case it's being used to measure how fast the output shaft of the transmission - the part that goes to the wheels to turn them - is turning. There's a companion input shaft sensor that measures how fast the engine is turning and the difference between the two lets the transmission computer know how efficient the transmission is operating and what speed and gear its running at.
In your car the input and output shaft sensors are mounted near one another underneath the valve body of the transmission. That means it's not an easy job to replace; you have to drain the transmission fluid, remove the transmission pan, and disassemble the valve body in order to get to it. It's doable, but does require what I'd call medium to advanced home mechanic skills. It's something I would personally tackle, but then again I've been wrenching on my own cars for a good 50 years.
Those sensors can fail for any number of reasons. It could be a problem with the wiring, the sensor itself or the transmission computer's circuitry that reads the sensor. Most of the wiring harness that typically fails on that part is once again inside the transmission so even checking that requires the same disassembly I mentioned earlier.
Here's a video that shows the procedure for replacing the sensors; they finally get to where you can see them at about 10:45 into the video.
HYUNDAI INPUT OUTPUT SPEED SENSOR LOCATION REPLACEMENT SONATA ELANTRA SANTA FE TUCSON VELOSTER ACCEN - YouTube
There's a discussion of this over on the Hyundai forums that also includes a video.
2016 hyundai elentra output speed sensor - Hyundai Forums
One user has an additional comment that might be of interest.
If you going to tear the thing apart, I would suggest you replace the internal harness also, especially if the plug on top of the transmission case is black. the new part has a brown connector. the black harness was had concerns with solder joints at the main connector, and new part has temp sensor integral to harness, not 2 piece.
Refill with proper Hyundai ATF, usually a bit over 5 bottle is needed to do it
So something else to consider if you decide to tackle this yourself.
Good luck with your repair; let us know what you decide to do and how it turns out!