Actually i didn't get your scenario very well,do you want to connect to docker container from your playbook?
if that is the case you can add ssh public key 'id_rsa.pub' (generate this file by the command ssh-keygen
inside the instance from where you want to connect to docker) to authorized_keys file inside docker container. When shh keys are there you don't need a sudo password.
You can do this in either in Dockerfile or using ssh-copy-id
if you are not using ssh, and having this error while running task with 'become: true' or 'become: sudo', then add the following line to /etc/sudoers list
<username> ALL=NOPASSWD: ALL