Stalling a diesel engine every now and then by accident shouldn't cause much if any harm to the diesel engine.
But if you stall the diesel engine just because you want to then it could cause damage to the diesel engine over time and also cause problems with the diesel engines fuel injectors and other fuel related components.
However if you just happen to be driving a diesel with a stick shift and stall it accidentally then there's not much to worry about.
A diesel engine is actually more robust than a gasoline engine so it can handle more abuse than a gasoline engine can.
I've known a few people who had to stall a run away diesel engine on the highway to stop the engine from running and destroying itself more or before it caused a wreck.
If you can while going down the highway or road with your diesel powered truck and it runs away then you can try stalling the diesel engine to stop it.