For that first you need to create a shortcode as per your requirement (Use Post type as Product for WooCommerce). Afer that please use the shortcode in wooCommerce shop page. Remove the shortcode they have there and place this one. Now you will have masonry layout in your shop page.
Regarding the categories, masonry can’t be used in category template. So you need to create shortcode for each category and place them in a page.