It is true. The cause of death is confidential medical information and confidentiality does not stop with death. The hospital cannot legally release that information without consent of next of kin. There is a legal requirement for a doctor to certify cause of death, and that certificate has to be presented to the registrar of deaths etc. by the next of kin*. A copy of that certificate then goes to central statistics office that record data such as age sex etc. so national statistics can be produced. The office has a legal duty to produce reports so are not bound by confidentiality. Since the numbers are aggregated over an area and time rather than being from a specific hospital on a particular day the data is far more anonymous.
Since Covid-19 is a notifiable infectious disease there is a separate requirement to notify all cases to the local public health department, effectively this is done by an end of day line listing emailed to the department. again there is then a national collection of data.
* This may be done electronically.