Setting user permissions per post

I am trying to assign privileges on posts on a per post basis.

Essentially, I have a custom post type which have authors. They can edit their own posts.

I then have another role, which should be able to edit a subset of those posts bases on a custom field or taxonomy.

I can filter out the posts that appear in the backend using pre_get_posts, and applying a query based on the custom field. However I need to limit specifically edit privileges for each post.

Does anyone know if it’s possible to apply an “editable” filter per post rather than a blanket privilege based on the role?