I was able to find in the documentation on how to create AMI images from the running instance. But I am not able to change it to public visibility.
If you look at the CLI example, you can do this via the command:
aws ec2 modify-image-attribute --image-id ami-0abcdef1234567890 --launch-permission "Add=[{Group=all}]"
So if you want to achieve this using Lambda, you need to use the modify_attribute, resource action.