I want to randomly sample three variables that are conditioned by $$x_1 \le x_2 \le x_3$$ and $x_1\in [0,\, \ell]$, $x_2\in [0,\, \ell-\ell_1]$ and $x_3 \in [0, \,\ell-\ell_1-\ell_2]$.
I have only limited statistics knowledge. Would you help me on how to do this using Matlab?
Your ranges are inconsistent with your stated condition: $max(x_3)<max(x_2)<max(x_1)$ yet you are conditioning them to have the opposite general relationship. This will result in the actual range of x values being constrained to $x_3$'s interval of $[0, \,\ell-\ell_1-\ell_2]$.
To generate conditional values, you would choose them in succession:
Of course, you need to decide on a distribution for the x's (perhaps uniform distribution?) but following the above will get you the correct conditional values.