Scalarized Einstein–Maxwell-scalar black holes in a cavity