Update metafield value in Liquid

Hi

We have a system to schedule the display for a section. We added a start and end date for the section and, depending on the current date, it appears or not.

We’d want to avoid 2 sections to appear at the same time, even if the dates overlap.

It seems that the only way to pass a value across templates is using metafields, but we didn’t find if that was possible to set a metafield’s value from the template.

The idea is to have a metafield “banner_displayed”, set to false, and to set it to true in the template.

Is that possible?

Thanks