As *@nfdc23* points out, even in the simplest case of $\pi=\mathrm{id}_X$ your suggestion would amount to saying that for any two locally free sheaves of the same rank (at every point) there would be a line bundle that twists one to the other. Obviously this fails. On the other hand if one approaches the problem a little differently, then one can get a reasonable statement which generalizes the one that motivated you to ask. The essential case in the statement you quote is the following: >>Let $\pi:X \to S$ be a flat family of projective varieties and $\mathscr L$ a line bundle on $X$ such that for all $s \in S$, $\mathscr L_s \simeq \mathscr O_{X_s}$. Then there exists an invertible sheaf $\mathscr N$ on $S$ such that $\mathscr L \simeq \pi^*\mathscr N$. Then the statement you are quoting is a simple application of this for $\mathscr L\otimes \mathscr M^{-1}$. Now, if you think about it, the above statement is actually true for arbitrary locally free sheaves: >>Let $\pi:X \to S$ be a flat family of projective varieties and $\mathscr E$ a locally free sheaf of constant rank $q$ on $X$ such that for all $s \in S$, $\mathscr E_s \simeq \mathscr O_{X_s}^{\oplus q}$. Then there exists a rank $q$ locally free sheaf $\mathscr G$ on $S$ such that $\mathscr E \simeq \pi^*\mathscr G$. **Proof:** I claim that the same proof works. Indeed by the assumption, $h^0(X_s, \mathscr E_s)$ is constant, in fact equal to $q$, so $\mathscr G:=\pi_*\mathscr E$ is locally free of rank $q$ on $S$. Next we observe that by the assumption, the natural morphism $$ \alpha: \pi^*\pi_*\mathscr E\longrightarrow \mathscr E $$ is surjective. Since these are locally free sheaves of the same constant rank, this can only happen if $\alpha$ is an isomorphism. $\square$ Now if you want a true statement under your original assumptions, it will look something like this: >>Let $\pi:\mathcal{X} \to S$ be a flat, family of projective varieties (here $\mathcal{X}$ and $S$ are noetherian). Let $E$ and $F$ be two locally free sheaves on $\mathcal{X}$ such that for all $s \in S$, $E_s \cong F_s$, where $E_s$ and $F_s$ are the restriction of $E$ and $F$ respectively to the fiber $\mathcal{X}_s$ over $s$ of $\pi$. Then, does there exists a locally free sheaf $G$ of rank $r^2$ on $S$ such that $E \otimes F^\vee \simeq \pi^*G$. ...and the proof is the same: apply the previous statement for $E\otimes F^\vee$. And, of course, if $r=1$ this clearly gives you the original statement.