Template as the max_age of a statistics sensor

I noticed that the following does not work.

  - platform: statistics
    name: Statistics Starting at Midnight
    entity_id: sensor.processor_temperature
    state_characteristic: mean
    max_age: "{{ now().timestamp() | timestamp_custom('%H:%M:%S') }}"
    sampling_size: 100000

Is it simply that templating is not accepted here, or am I doing something wrong?

I was trying a way to do the same as the HADailySensor, a custom integration which aggregates until midnight, when it resets. Being able to use the statistics integration for this would make it more advanced.

Any other way I can achieve the same?

Yes.