I read this as a teenager in the 80s. It was possibly by Diana Wynne Jones, or a similar author.
The story involved some agents from an advanced culture helping out dissidents on a lower-tech planet ruled by a dictatorship. The agents knew how to access psychic powers that enabled them to do all sorts of things; crucially, though, this was something that everyone could learn to do with training.
One of the female agents was imprisoned with another woman, a citizen of the low-tech culture. They were both due to be tortured; the agent however would feel no pain under torture thanks to her psi powers. In an attempt to activate her fellow prisoner's own powers, she gave her some fake pills, actually just breadcrumbs, telling her they would make her immune but knowing that really they would give her the confidence to use her own inbuilt psi: basically, the same principle as Dumbo and the crow's feather.
This worked at first and the prisoner failed to suffer; there's a description of them acting as if they were in terrible pain, so that the torturers wouldn't suspect anything was up. However, before the next round of torture, the agent tried to give her some more pills, but failed to pretend to take them herself first; the prisoner refused to let the agent suffer. I don't remember how it was resolved.