(~numpy.isnan(A))*A
Changing the nodata value in geotiffs with NAN value with GDAL_CALC
General
GDAL
Rasters

If “nan” is present in geotiff, the expression should be as follows:
"(~numpy.isnan(A))*A"
Explanation: If pixel A is not NAN (~) the result returns TRUE, multiplied by the value of A.

Example :
gdal_calc.py -A input.tif --outfile=result.tif --calc="(~numpy.isnan(A))*A"
2025 Mar