Removing cloudy areas and export to geotiff

I want to determine possible methods to export to geotiff with the major cloud-free areas for each recorded sentinel-2 image and leave the rest as unknown values (0 or ex. -127). I know how to export to a geotiff with clouds but have been unable to mask them out or remove them completely. I am not trying to get a perfect result in SNAP, since I know clouds sometimes are overlook be the automated process.

I am trying to find a method to export Sentinel-2 data to geotiff from SNAP with cloudy areas set to 0 (or some fixed negative value) for all bands. What I want to export is NDVI (normalized difference vegetation index), RIEP(red edge inflection point) and the Sentinel-2 bands (1-12), for areas that seem to be without clouds, shadows from clouds or other covering atmospheric objects.

Currently, I am following these steps:

  1. Load a MSIL1C sentinel-2 product
  2. Run sen2cor to get a MSIL2A product
  3. Resample all bands to 10m, using Raster->“Geometric operations”->Resample

After this step, I have attempted to use “land/sea mask” and the other mask functionalities under Raster, but I have been unsuccessful so far.
I can see the cloud, and shadow masks are present in the project, but I have been unable to utilize them to create a cloud-free geotiff.

Probably the best way to set all cloudy pixel to a certain value is to use the BandMaths operator.
Within the GUI it would be tedious to do it. But you can gpt from the command line and use a graph XML file.
For each band you want to filter you add a targetband section to the BandMaths node

...
<targetBand>
  <name>B1</name>
  <expression>(scl_vegetation || scl_bare_soil_desert || scl_water || scl_snow_ice) ? B1 : -999</expression>
  <description></description>
  <type>float32</type>
  <noDataValue>NaN</noDataValue>
</targetBand>

This expression will set the value of B1 if one of the masks is set, in other cases -999 will be written to the output.
In order to improve performance, you can externalise the validation expression part to a variable and use this variable in the expression.

Please have also a look at the help which is printed on the console when you type gpt -h or gpt -h BandMaths.