I'd suggest looking at Azure Automation for most needs that are beyond a simple start/stop schedule.
You can create a runbook that runs each night that inspects the Flexible server state, and then takes the appropriate stop/start action.
There are other options such as leveraging Event Grid and your Azure Activity Log, but I'd suggest that they would be too complex for such a simple scenario. You'd end up using 3 or 4 Azure components to perform a simple maintenance task.
Azure Automation Runbooks provide a simple, flexible environment to write custom scripts to interact with the Azure control plane.