it is the same exact process with only one difference the "script" part. you have to build a P2W{X}H script where {X} is pubkey or script.
if your bech32 address is a P2WPKH equivalent address then your script is going to be this:
OP_0 <20 bytes hash>
where hash is the result of RIPEMD160(SHA256(pubkey))
and if your bech32 address is a P2WSH then your script is:
OP_0 <32 bytes hash>
where hash is the SHA256(script)
now that you have your script, hash it using SHA256 just like the example in docs, reverse it and send that to server. i believe this should work.
I enquire the balance of P2WSH like this:
Address: bc1qrlam06agczxvm4fzlaumcp8q20gh3xfy28r3qg9xlr5rrc6e48jq4ghzey
Pubkeyhash: 1ffbb7eba8c08ccdd522ff79bc04e053d178992451c71020a6f8e831e359a9e4
Hash = SHA256(HEX2BIN(Pubkeyhash)) = 4899cf970298cf69b162d33b16db0c917935d11ce5908d63c7fba1893b23b581
Then I flip it to reverse its endianness:
81b5233b89a1fbc7638d90e51cd13579910cdb163bd362b169cf980297cf9948
Then I send it to Electrumx as an argument of blockchain.scripthash.get_balance
and it returns zero while this address for sure has some positive balance
No error message but something is wrong with the hashes I guess