### Description

When using the DiffableUtils.diff with a vanilla OpenJDK Map, instead of the legacy ImmutableOpenMap interface, we return a mutable map (generic HashMap), which isn't the expected behaviour of the API:

https://github.com/elastic/elasticsearch/blob/45c56b22f946733712ad6d92600411c0885594c5/server/src/main/java/org/elasticsearch/cluster/DiffableUtils.java#L85

We should wrap the map returned by the diff API in an unmodifiable version.
server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java
for (IndexTemplateMetadata template : metadata.templates().values()) {
                IndexTemplateMetadata.Builder.toXContentWithTypes(template, builder, params);
            }
            builder.endObject();
            if (context == XContentContext.API) {
                builder.startObject("indices");
                for (IndexMetadata indexMetadata : metadata) {
                    IndexMetadata.Builder.toXContent(indexMetadata, builder, params);
                }
                builder.endObject();
            }
            for (Map.Entry<String, Custom> cursor : metadata.customs().entrySet()) {
                if (cursor.getValue().context().contains(context)) {
                    builder.startObject(cursor.getKey());
                    cursor.getValue().toXContent(builder, params);
                    builder.endObject();
                }
            }
            builder.startObject("immutable_state");
            for (ImmutableStateMetadata immutableStateMetadata : metadata.immutableStateMetadata().values()) {
                immutableStateMetadata.toXContent(builder, params);
            }
            builder.endObject();
            builder.endObject();
        }
        public static Metadata fromXContent(XContentParser parser) throws IOException {
            Builder builder = new Builder();
            // we might get here after the meta-data element, or on a fresh parser
            XContentParser.Token token = parser.currentToken();
            String currentFieldName = parser.currentName();