The main trick in such gallery layout customization it’s config of the columns in layout gallery settings.
When you open gallery settings you can find Columns option in Size gallery settings block. In this settings grid you can change amount for the gallery columns for different screen size.
At the same size every photo gallery image have columns option in additional settings panel in gallery images manager. You can specify how much columns every image gonna take. By default it’s one column.
In combination of the general gallery columns amount and this value for every gallery image you can build layout like you see here: https://wpape.net/demo/wordpress-gallery-linked-thumbnails-shadow/
For example in this gallery demo big images take 3 columns from 5 in general gallery layout.
Please try and let me know.