ST_ConcaveHull
is what you're looking for. This function calculates the concave geometry of a given geometry (its vertices) and returns a single geometry.
Consider the following MultiPolygon
MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)), ((20 35, 45 20, 30 5, 10 10, 10 30, 20 35), (30 20, 20 25, 20 15, 30 20)))

The function ST_ConcaveHull
expects a second parameter, which sets the concaveness of the computed hull:
The param_pctconvex controls the concaveness of the computed hull. A value of 1 produces the convex hull. A value of 0 produces a hull of maximum concaveness (but still a single polygon). Values between 1 and 0 produce hulls of increasing concaveness. Choosing a suitable value depends on the nature of the input data, but often values between 0.3 and 0.1 produce reasonable results.
Check which value for param_pctconvex
best fits your use case. Setting it to 0.1 gives you the following polygon:
WITH j (geom) AS (
VALUES ('SRID=4326;MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),
((20 35, 45 20, 30 5, 10 10, 10 30, 20 35),
(30 20, 20 25, 20 15, 30 20)))'::geometry)
)
SELECT ST_ConcaveHull(geom,0.1) FROM j

Alternatively you can set a third (boolean) parameter to allow holes in the output:
The polygon will not contain holes unless the optional param_allow_holes
argument is specified as true