Following the examples in https://www.ddev.com/ddev-local/customizing-ddev-local-images-with-a-custom-dockerfile/ and the example Docker file, I tried to composer global require drupal/coder:
ARG BASE_IMAGE=drud
FROM $BASE_IMAGE
RUN composer global require drupal/coder:8.3.5 --verbose
RUN composer global require dealerdirect/phpcodesniffer-composer-installer --verbose
RUN export PATH="$PATH:$HOME/.composer/vendor/bin"
RUN phpcs --config-set installed_paths ~/.composer/vendor/drupal/coder/coder
This didn't work as expected, as it installs for root. However the user that will later try to invoke it, isn't root.