You can do it with GDAL in two steps:
- pick the correct decoder (Terrarium vs Mapbox Terrain‑RGB),
- apply the formula to the RGB PNG tiles inside the MBTiles and write out a Float32 GeoTIFF (then optionally reproject to WGS84).
Below I give ready‑to‑run commands for both encodings, plus tips to choose the zoom level, mask with the alpha band, and reproject.