I don't know if they can require it in Japan. They can require it in the US, in Canada, in the UK, in Australia, and many others.
In Canada, I believe they would just seize the device if you don't give them the password. In the UK and in Australia, I believe they send you to jail...
Conclusion : no electronic device when flying.
By the way, do you know if you can opt-out of the body scanner in Japanese airports? I believe you can in Europe, Canada and in the US. You can choose to get a pat-down instead. But I don't know about Japan. Any thoughts?