The most common method to change vector geometries to raster is using the ST_AsRaster function. The only drawback is that it needs reference raster geometry.
CREATE TABLE raster_ops.admin_rast AS
SELECT ST_Union(ST_AsRaster(geometry, rast, '32BF', '1', -9999)) rast
FROM raster_ops.admin, (SELECT rast FROM eudem.clip LIMIT 1) rast;
This function allows you to set values of raster pixels according to attribute value, in our example, the height column.
CREATE TABLE raster_ops.admin_rast AS
SELECT ST_Union(ST_AsRaster(geometry, rast, '32BF', height, -9999)) rast
FROM raster_ops.admin, (SELECT rast FROM eudem.clip LIMIT 1) rast;