The Worpitzky identity in groups of types B and D