you would need to use code to dynamically lock / unlock, however could you use Data Validation rule on your C range relative to value in D?

e.g. highlight C4:C6 and apply a Custom Data Validation rule of:

Formula: copy to clipboard
=ISNUMBER(C4)*(D4<>"Yes")


if C4 is non-numeric, or D4 is Yes, the entry attempt would fail...