There is no built-in way to retrieve expiring client secrets, but you can use MS Graph to fetch them and the Send-MgMailUser cmdlet to send alert notifications.
As a workaround, you can use this PowerShell script from GitHub: Get expiring certificates and client secrets
You can enhance the script by including the Send-MgMailUser cmdlet to send email notifications. The script also supports scheduling, so you can configure it in Task Scheduler with the following format:
.\AppRegistrationsWithExpiringCertAndSecrets.ps1 -ClientSecretsOnly -SoonToExpireInDays`` ``30
When scheduled, the script will check for app registrations with client secrets expiring in less than 30 days. It will then send an alert to the configured email address automatically.