I have a late 2014 iMac now upgraded to Sierra. When using El Captain I had instances where the password field was filling with random characters. After upgrading to Sierra the problem appeared to go away but returned quite recently. The solution I used for the original problem was to turn off the keyboard and turn it back on again. Others have said they turned off their trackpad which also resolved the problem. I now understand the problem a bit more. I have the keyboard of course, the trackpad and a smart-mouse. If I have all three on the problem occurs.
Just yesterday I had random characters appearing again in the password field. I turned off the mouse; highlighted the random text in the password field with my trackpad and typed without any problems. So the work around is simple, you can only use the Mac with either a trackpad or a smart-mouse to avoid the problem. You can't have both on at the same time as the combination of all three devices occasionally interferes with the keyboard signal, generating random characters. There maybe something Apple can do in software but I suspect that a hardware fix for Bluetooth is needed for those of us that use keyboard, trackpad AND mouse.