### Elasticsearch Version

All

### Installed Plugins

N/A

### Java Version

_bundled_

### OS Version

N/A

### Problem Description

Today if an index has an `index.auto_expand_replicas` setting which cannot be realised in the cluster then the number of replicas is left unchanged by `AllocationService#adaptAutoExpandReplicas()`. Instead, I think we should change the number of replicas to the closest value within the permitted range.

For instance: if a cluster has a single data node which is marked as shutting down for restart then auto-expand replicas considers this cluster to have zero data nodes, and hence requires -1 replicas. If an index is created with `index.auto_expand_replicas: "0-1"` then it will not be adjusted to have zero replicas, even though this would be better than leaving it at the default value of 1 replica, and will ultimately be the correct setting.

### Steps to Reproduce

1. Create a cluster with one data node.
2. Put a `RESTART` shutdown marker on the data node.
3. Create an index with `index.auto_expand_replicas: "0-1"`
4. Observe that this results in an unassigned replica.

### Logs (if relevant)

_No response_
server/src/test/java/org/elasticsearch/cluster/metadata/AutoExpandReplicasTests.java
}
        try {
            AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "1-boom").build());
            fail();
        } catch (IllegalArgumentException ex) {
            assertEquals("failed to parse [index.auto_expand_replicas] from value: [1-boom] at index 1", ex.getMessage());
            assertEquals("For input string: \"boom\"", ex.getCause().getMessage());
        }
        try {
            AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "boom-1").build());
            fail();
        } catch (IllegalArgumentException ex) {
            assertEquals("failed to parse [index.auto_expand_replicas] from value: [boom-1] at index 4", ex.getMessage());
            assertEquals("For input string: \"boom\"", ex.getCause().getMessage());
        }
        try {
            AutoExpandReplicas.SETTING.get(Settings.builder().put("index.auto_expand_replicas", "2-1").build());
        } catch (IllegalArgumentException ex) {
            assertEquals("[index.auto_expand_replicas] minReplicas must be =< maxReplicas but wasn't 2 > 1", ex.getMessage());
        }
    }
    private static final AtomicInteger nodeIdGenerator = new AtomicInteger();
    protected DiscoveryNode createNode(Version version, DiscoveryNodeRole... mustHaveRoles) {
        Set<DiscoveryNodeRole> roles = new HashSet<>(randomSubsetOf(DiscoveryNodeRole.roles()));
        Collections.addAll(roles, mustHaveRoles);
        final String id = String.format(Locale.ROOT, "node_%03d", nodeIdGenerator.incrementAndGet());
        return new DiscoveryNode(id, id, buildNewFakeTransportAddress(), Collections.emptyMap(), roles, version);
    }
    protected DiscoveryNode createNode(DiscoveryNodeRole... mustHaveRoles) {
        return createNode(Version.CURRENT, mustHaveRoles);