I would rather start by preparing bands that can be combined directly into desired result instead of updating pixels of that 4 band image.
You need
- band 1 to be used as band 1
- band 2 to be used as band 4
- two dummy bands to be used as bands 2 and 3
You know already how to get the first two
gdal_translate -of GTiff -b 1 Filein.tif band1.tif
gdal_translate -of GTiff -b 2 Filein.tif band2.tif
A dummy band can be created with gdal_create utility https://gdal.org/programs/gdal_create.html. Notice that you need GDAL version 3.2 or newer. What you want is an image that takes most features from the source image, but has only 1 band with all pixels having a fixed value, let's say "0".
gdal_create -bands 1 -burn 0 -if Filein.tif dummy.tif
Finally you can combine the ingredients with gdal_merge https://gdal.org/programs/gdal_merge.html. Notice that you must have GDAL Python bindings installed for running gdal_merge because it is a python script. You want to take 4 input files and write them into one GeoTIFF, each input on a separate band.
Notice also that your assumption that updating a whole band into nodata would automatically save space. It does not because in an uncompressed TIFF every pixels requires the same amount of space. Fortunately a band with all equal pixels is compressing extremely well even with lossless compression methods like "deflate". Thus the gdal_merge command would look as follows. Notice that the dummy TIFF is selected twice.
gdal_merge -o 4bandtest.tif -of GTiff -co compress=deflate -co tiled=yes -separate b1.tif dummy.tif dummy.tif b2.tif
Check with gdalinfo proves that the result has 4 bands and bands 2 and 3 have just zeroes.
gdalinfo 4bandtest.tif -stats
Driver: GTiff/GeoTIFF
Files: 4bandtest.tif
...
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
Minimum=0.000, Maximum=255.000, Mean=63.804, StdDev=31.731
Mask Flags: PER_DATASET ALPHA
Metadata:
STATISTICS_MAXIMUM=255
STATISTICS_MEAN=63.803541618056
STATISTICS_MINIMUM=0
STATISTICS_STDDEV=31.731235967103
STATISTICS_VALID_PERCENT=100
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
Minimum=0.000, Maximum=0.000, Mean=0.000, StdDev=0.000
Mask Flags: PER_DATASET ALPHA
Metadata:
STATISTICS_MAXIMUM=0
STATISTICS_MEAN=0
STATISTICS_MINIMUM=0
STATISTICS_STDDEV=0
STATISTICS_VALID_PERCENT=100
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
Minimum=0.000, Maximum=0.000, Mean=0.000, StdDev=0.000
Mask Flags: PER_DATASET ALPHA
Metadata:
STATISTICS_MAXIMUM=0
STATISTICS_MEAN=0
STATISTICS_MINIMUM=0
STATISTICS_STDDEV=0
STATISTICS_VALID_PERCENT=100
Band 4 Block=256x256 Type=Byte, ColorInterp=Alpha
Minimum=0.000, Maximum=255.000, Mean=68.127, StdDev=32.036
Metadata:
STATISTICS_MAXIMUM=255
STATISTICS_MEAN=68.126588152778
STATISTICS_MINIMUM=0
STATISTICS_STDDEV=32.036317455231
STATISTICS_VALID_PERCENT=100