If the literature in your DCC system's manual says how to do it, it must be safe to do. However, anybody I know who has tried it for giggles, and that includes me, has learned that it is NOT a rewarding experience. The pulsed and changing frequency of instructions on the AC wave to the rails makes the drive-train groan and squeal. I urge you to try it for yourself and see.
Just don't leave your loco on the rails, with power to the rails, and sitting there. You'll fry the can motor within a few minutes because it heats up.
I know that my Digitrax system, the Super Empire Builder, allows me to do this. I did it exactly once. I dialed in Add '00", the universal address for all decoders in the world of DCC, and then dialed in speed on the throttle. Good luck.