@Vasanth J While not the exact use case, this policy sample covers this. Here are the lines of importance for reference
@{
System.Security.Cryptography.HMACSHA256 hasher = new System.Security.Cryptography.HMACSHA256(<signing-key>);
return Convert.ToBase64String(hasher.ComputeHash(System.Text.Encoding.UTF8.GetBytes(<string-to-sign>)));
}
As for the policy code that you've shared, it's in JS whereas APIM uses C# for its policy expressions embedded in XML.