If I have understood correctly, then the following formula should do the task you are aiming for, note that the formulas exclusively works with MS365 per the tags posted.

• Method One:
=LET(
a, TEXTSPLIT(B2,,"|"),
b, TEXTBEFORE(a,"_"),
DROP(GROUPBY(b,a,LAMBDA(x,TEXTJOIN("|",1,x)),,0),,1))
• Method Two:
=LET(
a, TEXTSPLIT(B2,,"|"),
b, TEXTBEFORE(a,"_"),
c, UNIQUE(b),
MAP(c,LAMBDA(x,TEXTJOIN("|",1,FILTER(a,b=x)))))
Or, With ETA :
=LET(
a, TEXTSPLIT(B2,"_","|"),
b, TAKE,
DROP(GROUPBY(b(a,,1),b(a,,1)&"_"&b(a,,-1),LAMBDA(x,TEXTJOIN("|",,x)),,0),,1))
• For multiple rows of data then using REDUCE():

=DROP(REDUCE("",B2:B3,LAMBDA(x,y,
LET(z, TEXTSPLIT(y,"_","|"),
w, TAKE, VSTACK(x,
DROP(GROUPBY(w(z,,1),w(z,,1)&"_"&w(z,,-1),
LAMBDA(v,TEXTJOIN("|",1,v)),,0),,1))))),1)