It seems like the plugin always tries to find a key in the ~/.ssh/id_rsa file. If the key is encrypted, then Ansible prints the following:
Private key file is encrypted\nTo connect as a different user, use -u <username>.'
If the key is not in this directory then the following is printed:
FAILED: not a valid EC private key file
I also tried using ssh-agent plugin, but it seems like the ansible plugin does some setup that makes Ansible ignore the keys added to the agent. Encrypted keys are correctly read when Ansible is run by executing shell command via Jenkins, using the ssh-agent plugin.