$\newcommand{\cf}{\operatorname{cf}}$ Exercise 5.29 of Jech's Set Theory says:
If $\kappa$ is a singular cardinal such that $2^{\cf{\kappa}} < \kappa \leq \lambda^{\cf{\kappa}}$ for some $\lambda < \kappa$, then $\gimel(\kappa) = \gimel(\lambda)$ where $\lambda$ is the least $\lambda$ such that $\kappa \leq \lambda^{\cf{\kappa}}$.
Note that the gimel function is defined on all cardinals by $\gimel(\kappa) := \kappa^{\cf(\kappa)}$.
It's not difficult to prove $\gimel(\kappa) \leq \gimel(\lambda)$, but I can't see the converse inequality. Below is my work thus far:
By Theorem 5.20(ii), we have that $\gimel(\kappa) = \kappa^{\cf(\kappa)} = \lambda^{\cf(\kappa)}$. If $\mu < \lambda$ and $\mu^{\cf(\kappa)} \geq \lambda$, then $\mu^{\cf(\kappa)} = \lambda^{\cf(\kappa)}$, contradicting minimality of $\lambda$. Thus, we must have that $\mu^{\cf(\kappa)} < \lambda$ for all $\mu < \lambda$. We now consider two cases.
Suppose $\cf(\lambda) > \cf(\kappa)$. Clearly $\gimel(\kappa) = \lambda^{\cf(\kappa)} \leq \lambda^{\cf(\lambda)} = \gimel(\lambda)$. (How to proceed the other direction?)
Suppose $\cf(\lambda) \leq \cf(\kappa)$. Then $\lambda^{\cf(\kappa)} = \lambda^{\cf(\lambda)} = \gimel(\lambda)$, as desired.
Am I in the right direction?
Your observation that the minimality of $\lambda$ implies $\mu^{\operatorname{cf}\kappa}<\lambda$ for all $\mu<\lambda$ combined with the fact that $2^{\operatorname{cf}\kappa}<\kappa$ (so $\lambda\ne 2$) means we are in the situation where either $\lambda^{\operatorname{cf}\kappa} = \lambda$ or $\lambda^{\operatorname{cf}\kappa} = \lambda^{\operatorname{cf}\lambda}.$ But the former is contrary to the assumptions since $\lambda < \kappa \le \lambda^{\operatorname{cf}\kappa}.$ Thus, $\lambda^{\operatorname{cf}\kappa}=\lambda^{\operatorname{cf}\lambda},$ which, combined with your observation that $\kappa^{\operatorname{cf}\kappa}=\lambda^{\operatorname{cf}\kappa},$ proves the statement.
Or in other words, the situation $\operatorname{cf}(\lambda)>\operatorname{cf}(\kappa)$ that you were concerned with is impossible, since it would imply $\lambda^{\operatorname{cf}\kappa}=\lambda <\kappa.$