I found the way, so simple (I leave the question for if someone has the same issue in the future).
I made one tag for each dynamic layer: legatoDyn1 and legatoDyn2.
Then the sustains get silenced by both tags and the each legato dynamic layer get silenced only by itself:
<group name="SustainsDyn1" tags="sustains" release="0.3" silencedByTags="legatoDyn1,legatoDyn2" trigger="first">
<group name="SustainsDyn2" tags="sustains" release="0.3" silencedByTags="legatoDyn1,legatoDyn2" trigger="first">
<group name="LegatoDyn1" tags="legatoDyn1" release="0.3" silencedByTags="legatoDyn1" trigger="legato">
<group name="LegatoDyn2" tags="legatoDyn2" release="0.3" silencedByTags="legatoDyn2" trigger="legato">