Calculating, No. Looking up, Yes.
Pre-calculated data is available for the various Geoid models (EGM84, EGM96, EGM2008) in raster format. Here's an easy to use source:
https://sourceforge.net/projects/geographiclib/files/geoids-distrib/
or
https://geographiclib.sourceforge.io/html/geoid.html#geoidinst
The raster files can be imported into your db using raster2pgsql. For example:
raster2pgsql -s 4326 -I -C -M egm2008-1.tif -F -t 100x100 myschema.geoid_egm2008 | psql -h localhost -p 5432 -U user -d db
And then querying:
SELECT ST_Value(rast, ST_SetSRID(ST_MakePoint(mod(-75.49393 + 360,360), 39.96002),4326))::numeric * 0.003 - 108
FROM myschema.geoid_egm2008
WHERE ST_Intersects(rast, ST_SetSRID(ST_MakePoint(mod(-75.49393 + 360,360), 39.96002),4326));
--Should be ~ -33.9943
Note the scaling & offsetting spec:
# Offset -108
# Scale 0.003
# Origin 90N 0E
Explanation here: https://geographiclib.sourceforge.io/html/geoid.html#geoidformat
See here and here for further information on raster2pgsql tile size optimization and querying raster data.