Can I die if I have soul hearts but lose all my red hearts, either from making a deal with the devil or using the razor or using the blood donation machine?
Strictly speaking, whenever you lose all of your regular health you will die. However, this is not always easy to do when you have soul hearts. I'll treat each of the cases you listed individually:
Blood donation machine: On levels before the womb, blood donation machines do half a heart of damage. You'll start by losing regular hearts, until you have half a heart left, and then you'll start losing soul hearts (Source. I haven't felt suicidal enough in any of my playthroughs to actually try this out):
Starting at the womb, using the blood donation machine will use up a whole heart, so if you only have one heart left, using the machine will kill you.
Razor: This acts more or less like the blood donation machine, except the loss of regular hearts scales up more quickly (1/2 heart in basement/caves, 1 heart in Depths, 2 hearts in the Womb).
Making a deal with the devil: While making a deal with the devil is slightly different than the above as it will actually cost you heart containers instead of causing you damage, you will still get killed even if you have soul hearts left after the deal. Some consider this to be a bug, though that is debatable (see the bugs section here).
And of course, all of the above doesn't really apply to ???, who has no regular hearts to begin with, and cannot gain them.
Just tested it. Donation machine kills you, even if you have more soul hearts than the screen can show.