Torque under your control (with limited accuracy of course) is easy, because the torque produced is directly proportional to current, and current control is what every properly designed motor controller must start with, anyway. Just implement the current control as usual. If you don't need speed regulation, then one less thing to do.
What this "as usual" is? Implementing BLDC FOC from scratch is quite some work, though. It's really simple once you grok the idea, but it takes some time in the rabbit hole of confusing information. If you want it easier, start with brushed DC motor which abstracts away some of the math at mechanical level.
The basics are the same: control the voltage applied to the motor windings with a MOSFET halfbridge(s) (one for unidirectional brushed, two for bidirectional brushed, three for BLDC), allowing you to apply Vcc or GND to each of the wires. Measure motor current (for example, with a shunt resistor in series with the lower leg of the MOSFET, sampled by ADC while the bottom MOSFET is conducting (microcontrollers offer such synchronization possibilities in hardware)), compare to your current setpoint value using a PI feedback loop which outputs the PWM duty cycle. If current is lower than it should be, the control loops increase the duty ratio, applying higher average voltage to the motor, making the current increase. And vice versa. This PI loop is not that critical or difficult to tune. Motor current is a nice triangle wave which increases when the full supply voltage is applied and decreases when the motor is "shorted".
If you use a BLDC (AC permanent magnet motor), all of that applies, but the differences are: instead of one current, you have three, so you would measure two of the phase currents and calculate the third (from the fact that sum is zero). Then you do a bit of extra math: apply 3-axis-to-2-axis transformation to the current measurements (get 2D vector out of 3 values), then apply 2D vector rotation in sync with the measured* rotor position so that you have "stationary" current measurement just like you did with the DC motor, then apply the same PI loop to that stationary value, outputting stationary PWM duty cycle value, which you again make rotate by the opposite 2D vector rotation, 2-axis-to-3-axis transformation, then apply to the MOSFET stages. Basically you have to rotate both the measurement and outputs in software, because you don't have the mechanical brushes which do this on a classic DC machine.
*) approximating it with algorithms instead of measuring makes the problem harder again, and is inferior at low speeds, so measure if at all possible