Creating digital signature for API requests in bash

I have a python script to create signature/token for API requests. It works fine.
I have written almost all lines from python to bash. Now I am not able to decode/translate below lines from python to bash so that correct signature gets created and I complete my bash script.

    # Load private key
    try:
        with open(private_key_location, 'r') as file:
            # Read the contents of the file
            private_key_string = file.read()

    # Load private key
    private_key = RSA.import_key(
    private_key_string, passphrase=passphrase if passphrase else None)

    # Sign
    h = SHA256.new(signing_string.encode('utf-8'))
    signature = pss.new(private_key).sign(h)

    # Encode
    encoded_signature = base64encode(signature)

First thing I get stuck is this line signing_string.encode('utf-8') as in python it will create a byte string b'. I tried iconv in bash for byte string but doesn’t seem to fill the purpose. But I may be wrong.

Second thing I tried to sign and all is using below command in bash.

echo -n $MESSAGE | openssl dgst -sha256 -hmac $SECRET -binary | base64 this outputs few number of characters which when I run python one, gives alot of characters wrapped in multiple lines.
Tried below too,
echo $MESSAGE | openssl dgst -sha256 -sign private.pem | base64 this gives alot of characters wrapped in multiple lines like python one, but doesnt generates the correct signature for server to authorize, so logic problem.

Need help in translating python code above to bash to be able to generate signature.

I know I can go ahead and use this whole code in bash using python -c "" command etc, etc, but my goal is pure bash script.