How to inject attributes into get_the_post_thumbnail?

You need to use get_the_post_thumbnail_url (the one you’re using echo‘s the URL).

get_the_post_thumbnail( $the_post_id, 'medium', [
    'data-zoom-image' => get_the_post_thumbnail_url( $the_post_id, 'full' ),
]);