If your gallery field is not a sub field of a group or repeater then the meta query would look something like this:
'meta_query' => array(
array(
'key' => 'gallery_field_name',
'value' => '"'.$attachment_id.'"',
'compare' => 'LIKE'
)
)
If it’s a sub field then it gets far more complicated, see the section on sub fields here https://www.advancedcustomfields.com/resources/query-posts-custom-fields/