Modified gravity from the nonperturbative quantization of a metric