How can I set a custom field based on membership in a smart group?
In your own cron job you could reload the cache for groups by calling civicrm_api3_job_group_rebuild() (https://github.com/civicrm/civicrm-core/blob/master/api/v3/Job.php#L629), then cycle through the group to fill your custom field.