Insering MIDI commands.

Sibelius allows me to insert MIDI commands such as ~P42,0,60 (where the twiddle means that it does not show when the score is printed).

How can I insert similar commands into a Dorico score?

There isn’t yet a general mechanism for this, but the question is what are you trying to achieve? If you are triggering keyswitches and controller switches then you probably want to be using an expression map.