Update for the community:
APIM is deployed in VNET - Internal mode and integrated with Application Gateway as per docs: Integrate API Management in an internal virtual network with Application Gateway. The direct call to backend API works from browser but when testing it from the azure portal using Test option, it returned 502 error.
@Danilo Kasparian restarted Application Gateway after following docs: https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-backend-health-troubleshooting and it resolved the issue.
Application Gateway must be restarted after any modification to the backend server DNS entries to begin to use the new IP addresses. This operation can be completed via Azure PowerShell or Azure CLI.