Add caption to thumbnails in content

 <figure>
  <?php echo get_the_post_thumbnail( null, $size, $attr ); ?>
  <figcaption>here goes your caption</figcaption>
</figure> 

for the_post_thumbnail check : https://developer.wordpress.org/reference/functions/the_post_thumbnail/