nl does have the ability to only number lines matching (basic) regex. But it still leaves extra spaces which may not be acceptable to you. Notice the alignment of the second and last line.
nl -s' ' -nln -b'p^[^ ]' -w1 file
1 this line shall be numbered
this line shall not be numbered
2 this line shall also be numbered
this line shall not not be numbered