Can an outside scalar be used as a loss value?

Here is the situation:
I have an NN, which outputs a sequence of actions (an int in range of [0:3]) for a robot to perform in an environment. I can make the robot perform this sequence and save an array of (x,y,z) positions the robot visits while performing said actions. Then I can use Dynamic Time Warping to compare the resulted array of positions with the GT positions.

I would like to use the DTW value as loss. However, I don’t see any possibility to use it directly. The only solution I came up with, is to firstly perform cross-entropy between the predicted and GT action sequences and then multiply it by DTW using it as a sort of dynamic learning rate.

Is there any other method to use an outside value as a loss?