I can remember on what Stock ROM I was ,because I have the same problem, and I was changing ROM from Chinese to India ROM, so after I found out for these advanced settings that solve my problem. I have luck , I was delete persist.img in TWRP that cause this problem with fingerprint sensor
First to the menu using * # * # 6484 # * # *, then 3 dots on the top right and tools
The choice is the 12th fingerprint calibration
At first, the calibration is against a light surface, but a mirror is recommended (usually you attach it to a fingerprint reader). Then the calibration is against a dark surface. After that restart the phone.
I can't scan my fingerprint.