I know how to these two steps separately, but don't know how to combine them.
Ensuring a cell can be filled only if a dependent cell is filled can be achieved via inserting a
=NOT(ISBLANK($A$1)) formula in the Data Validation prompt, as explained here.
Limiting a cell to two possible values can be done via 'Data Validation' as explained in the answers to this question.
But how can I combine these two features? I don't think one can have two data validation options on one same cell.