Code:
awk '
NR==1 {print "Name", $0
next
}
{for (i=1; i<=3; i++) {T[$i]
R[$i,i] = 1
}
}
END {delete T[""]
for (t in T) print t, R[t,1]+0, R[t,2]+0, R[t,3]+0
}
' FS=, OFS=, file
Name,Set1,Set2,Set3
g1,1,1,1
g2,1,1,0
g3,0,0,1
g4,1,0,0
g5,0,1,1
g6,1,0,0
g7,0,1,0
g8,0,0,1