PostgreSQL - PostGIS ST_SetValues - int array cast to double and back
You're dong it wrong. I assume you're wanting a 32bit integer so you can bit shift around for RGBA (8bits per channel.) What you really want is a raster with 4 channels, 8 bits each. Because life will be easier.


ST_MakeEmptyRaster
ST_AddBand


Adapted from official docs...

SELECT
    *
FROM ST_BandMetadata(
    ST_AddBand(
        ST_MakeEmptyRaster(10, 10, 0, 0, 1, -1, 0, 0, 0),
        ARRAY[
            ROW(NULL, '8BUI', 255, 0),
            ROW(NULL, '8BUI', 255, 0),
            ROW(NULL, '8BUI', 255, 0),
            ROW(NULL, '8BUI', 255, 0)
        ]::addbandarg[]
    ),
    ARRAY[]::integer[]
);