Thanks a lot it saved my time. What I learnt is variable expansion and single quotes and remove double quotes using tr
oc image info registry.redhat.io/rhel9/httpd-24:9.5-1740962963 --filter-by-os linux/amd64 -o json | jq .digest | tr -d '""' | xargs -i sh -c 'IMGID="{}"; echo "$IMGID"'
sha256:f97c915312cdaa8f4000d409e71ead6e4aaeaed587563560e44e93532273e063