Lua, 205205 187 bytes
load("t="..( ...).."c=#t for i=1,c do c=math.max(c,#t[i])end p=load'iop=io.stdout:write(...)'p' p'{'for i=1,c do for j=1,c do _=j==1 and p'{'p(t[i]and t[i][j]or 0)p(j==c and'}'or',')end _=i~=c and p','end p'}'")()
Try it online!Try it online!
Human readable code:
load(
"t="..( ...)..
"c=#t
for i=1,c do
c=math.max(c,#t[i])
end
p=load'iop=io.stdout:write(...)'
p'{'
for i=1,c do
for j=1,c do
_=j==1 and p'{'
p(t[i]and t[i][j]or 0)
p(j==c and'}'or',')
end
_=i~=c and p','
end
p'}'
")
()