How can i set the trigger event to be a daily cron on memberships?
Goal is to check all memberships that has status pending for more than 40 days, if yes then change status to expired. I understand it would be a custom condition and action.
You can set the Membership status rule to end date as 40 days for pending status. But i am not confident that pending memberships are actually processed by 'Update Membership statuses' cron job.
You can develop your own cron trigger. There is no tutorial for that but take a look at the daily group membership cron trigger.
But as Pradeep suggested also take a look at the membership status rules and enable the update membership status cron.