The AzureAD module is not supported anymore, use the Graph SDK for PowerShell and the Add-MgApplicationKey cmdlet: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.applications/add-mgapplicationkey?view=graph-powershell-1.0
As mentioned in the documentation, this method requires "proof of possession", thus it can only be used if there is a credential already registered. Otherwise, use Update-MgApplication.