When you are merging two libraries in iCloud Photos, Photos will scan for duplicates when you are merging an additional library into your existing iCloud Photos Library, so each photo will only be stored once in iCloud Photos.
But this seems to be different, when two users are contributing to a Shared iCloud Photos Library.
I have just tested with my own Shared Library. When I shared photo to the shared library, that already has been added to the shared library from a different Apple ID, it will be added to the shared library without a warning about the duplication.
However, the Duplicates Album will show you the duplicates, once the library has been scanned. Once you are using a Shared iCloud Photos Library, the Duplicates album will only be shown, when you are viewing both libraries, the Shared library and your personal library together. So you can see, which photos in your personal library are already in the Shared library and can avoid to share them again.