Steps:
From your Shopify admin, go to Online Store -> Themes.
Find the theme that you want to edit, and then click Customize.
Choose Default product template in the dropdown of editor window to open theme editor of product page.
1. From Product Information -> Click Add block -> Choose Variant Picker.
2. Choose Show Variant Image Grouped? to enable Variant Image Grouped function.
3. In Admin -> Click "Products", then click on the product you would like to add Variant Images Grouped -> copy the colors of Variant section
Click “Alt” on Image -> Paste Color on “Image alt text” section corresponding to the image.
Here is the result: