You can start an interactive shell in a new image:
sudo docker run -i -t nginx /bin/bash
This gives you access to the container and you can change things. When done you need to save your changes in a new reusable image:
sudo docker commit <container_id> <some_name>
This approach makes sense for testing. Usually you would use Dockerfiles to automate this.
In case your image has a default entry point you can overwrite it:
docker run -i -t --entrypoint /bin/bash nginx