This can be tested by checking the existance of /proc/net/if_inet6
as follows:
test -f /proc/net/if_inet6 && echo "IPv6 supported" || echo "IPv6 not supported"
I've tested it on Ubuntu, Mint, Raspberry PI and Bash shell in Windows, and it works in all these environments.