$
\def\bb{\mathbb}
\def\H#1{{\bb H}^{#1}}
\def\C#1{{\bb C}^{#1}}
\def\R#1{{\bb R}^{#1}}
\def\s{\sigma}
\def\g{\gamma}
\def\l{\lambda}
\def\o{{\tt1}}
\def\bR#1{\Big[#1\Big]}
\def\lR#1{\Big(#1\Big)}
\def\BR#1{\left[#1\right]}
\def\LR#1{\left(#1\right)}
\def\op#1{\operatorname{#1}}
\def\sign#1{\op{sign}\LR{#1}}
\def\Imag#1{\op{\sf Imag}\LR{#1}}
\def\Real#1{\op{\sf Real}\LR{#1}}
\def\frob#1{\left\| #1 \right\|}
\def\a{\frob{a_v}}
\def\b{\frob{b_v}}
\def\q{\quad} \def\qq{\qquad}
\def\qif{\q\iff\q} \def\qiq{\q\implies\q}
\def\mq#1{\left[\begin{array}{r|rrr}#1\end{array}\right]}
\def\BEvec#1{\begin{Bmatrix}#1\end{Bmatrix}}
\def\fracBR#1#2{\BR{\frac{#1}{#2}}}
\def\fracLR#1#2{\LR{\frac{#1}{#2}}}
$You asked specifically about the cosine, but here is a derivation that works for most of the functions that you are likely to encounter, i.e. real analytic functions.
Consider the following scalar, vector, and quaternion quantities
$$\eqalign{
a_0 \in \R{1} \qq
a_v &= \BEvec{a_1\\ a_2\\ a_3}\in\R{3} \qq
a &= \{a_0,\: a_v\}\in\H{} \\
}$$
The quaternion $\,a\,$ can also be represented
as a $\sf Complex$ matrix
$$\eqalign{
A &= \mq{
\;a_0+ia_1 & \;a_2+ia_3 \\
\hline
\;-a_2+ia_3 & \;a_0-ia_1
}
}$$
The eigenvalues of $A$ are easy to calculate
$$\eqalign{
0 &= \det(\l I-A) \qiq \{ {\sf quadratic\ equation\ in\ }\l \} \\
\l &= a_0 \pm i\sqrt{a_1^2+a_2^2+a_3^2} \\
\l &= a_0 + i\a,\qq \l^* = a_0 - i\a \\\\
}$$
Consider a second quaternion given by
$$\eqalign{
b &= f(a) \;=\; \{b_0,\: b_v\} \\
}$$
This quaternion also has a matrix form $\lR{B=f(A)}$ with eigenvalues
$$\eqalign{
\mu &= b_0 + i\b
}$$
These eigenvalues are related to those of $A$ via the same function
$$\eqalign{
\mu &= f(\l) \;=\; \Real{f(\l)} + i\Imag{f(\l)} \\
}$$
Equating the real and imaginary parts yields
$$\eqalign{
b_0 &= \Real{f(\l)} \;\equiv\; \fracBR{f(\l)+f(\l)^*}2 \\
\pm\b &= \Imag{f(\l)} \;\equiv\; \fracBR{f(\l)-f(\l)^*}{2i} \\
}$$
We have everything but the direction of $b_v$.
One consequence of the Cayley-Hamilton theorem is that the function of an $n\times n$ matrix can be reduced to a polynomial of
degree $(n-1),\,$ therefore
$$ f(A) = \rho_0 I + \rho_1 A $$
Apply this polynomial to the quaternion form
$$\eqalign{
b &= \;\rho_0 + \rho_1 a \;\;\equiv\; f(a) \\
&= \big\{ \rho_0+\rho_1 a_0,\;\: \rho_1 a_v \big\} \\
}$$
This tells us that $b_v$ is parallel to $a_v$
Putting all of the pieces together
$$\eqalign{
f(a) &= \BEvec{
\Real{f(\l)},&
\Imag{f(\l)}\BR{\dfrac{a_v}{\a}} }
}$$
Let's apply this to your specific problem
$$\eqalign{
\cos(\l) &= \cos(a_0+i\a) \\
&= \cos(a_0)\cosh(\a) \;-\; i\sin(a_0)\sinh(\a) \\
\cos(a) &= \BEvec{
\cos(a_0)\cosh(\a),&
-\sin(a_0)\sinh(\a)\BR{\dfrac{a_v}{\a}} }
}$$