
If you want to set expiration for guest users (external users), you can configure an expiration policy for guest users in the Microsoft 365 admin center. This doesn't allow for a specific expiry date, but rather sets a policy for the duration after which the guest access will expire.
For normal Users: In Azure AD or Microsoft 365 (M365), there isn't a built-in feature to set a user's account to expire on a specific date. However, you can achieve this by using a combination of PowerShell scripts and Azure Automation or scheduled tasks. If you want to know how, let me know.
best regards
iohann gessenay