Of the torque definition can answer the question.
Each infinitesimal segment of wire with length ${\rm d}s$, direction $\vec{e}$ and located at $\vec{r}$ has an infinitesimal force ${\rm d}\vec{F}$ applied to it.
The net force applied is
$$\vec{F}_{\rm net} = \int {\rm d} \vec{F}$$
The net torque on the wire is adding up all the little segments.
$$\vec{\tau}_{\rm net} = \int \vec{r} \times \,{\rm d}\vec{F}$$
and due to magnetism the force is defined for each segment as ${\rm d}\vec{F} = (\vec{i} \times \vec{B}) {\rm d}s$
Now to answer your question, you need to evaluate the integral
$$ \vec{\tau}_{\rm net} = \int_0^\ell \vec{r} \times (\vec{i} \times \vec{B}) {\rm d}s$$
where the location varies along the wire $\vec{r} = \vec{r}(s)$.
Note that if the end-points of the wire are designated at $\vec{r}_1$ and $\vec{r}_2$ and the wire is a straight line you have
$$ \vec{r}(s) = \left(1 - \tfrac{s}{\ell}\right) \vec{r}_1 + \left(\tfrac{s}{\ell}\right) \vec{r}_2 $$
with the net torque
$$ \vec{\tau}_{\rm net} = \left( \int_0^\ell \vec{r} {\rm d}s \right) \times (\vec{i} \times \vec{B}) = \frac{ \vec{r}_1 + \vec{r}_2}{2} \times (\vec{i} \times \vec{B})$$
which is interpreted as the force acting on the center of mass of the wire, and then using $$\tau_{\rm net} = \vec{r}_{\rm com} \times \vec{F}_{\rm net}$$