Thanks @Sachin_Ghumbre . I was able to finally create a custom image using the below dockerfile. Thing I missed was the source image should have an environment to install and run commands.
FROM kong/kong-gateway:3.1.1.2-alpine
USER root
RUN apk update
RUN apk add lua5.1 lua5.1-dev luarocks5.1
RUN apk add gcc expat expat-dev expat-static musl-dev
RUN luarocks install xml2lua 1.5-2
USER kong
WORKDIR /usr/local/share/lua/5.1/kong/plugins
COPY kong/plugins/ ./ #Copy the plugin code from local to docker path
After building this custom image, I was able to start the container by passing this param,
-e “KONG_PLUGINS=bundled,custom-plugin-name”
This Video also gave me some more insight