This will not answer Timothy Chow's question about formalizing a sense of "needing to pick a basis as part of the proof", but rather it is a probing of the apparent skepticism that a basis-free proof is possible.
As I remarked in comments under the original post, if we work over arbitrary commutative rings $R$, one can define a trace operation
$$\hom_R(P, P) \to R$$
so long as $P$ is finitely generated projective over $R$. The idea is to establish that the canonical transformation
$$\phi_Q: P^\ast \otimes_R Q \to \hom_R(P, Q) \qquad f \otimes q \mapsto (p \mapsto f(p)q),$$
natural in $R$-modules $Q$, is an isomorphism. Then the trace is the composite
$$\hom_R(P, P) \overset{(\phi_P)^{-1}}{\to} P^\ast \otimes_R P \overset{\mathrm{ev}}{\to} R$$
where $\mathrm{ev}$ denotes the evaluation map $f \otimes p \mapsto f(p)$.
This is a perfectly "basis-free" description. Of course, in proving the claim that $\phi_Q$ is an isomorphism, one has to use the fact that $P$ is finitely generated projective somewhere; one could hardly do otherwise! And that fact is none other than the fact that $P$ is the image of some idempotent map $e: R^n \to R^n$.
Proof of claim: by naturality, there is a commutative diagram
$$\begin{array}{ccccc}
(R^n)^\ast \otimes_R Q & \twoheadrightarrow & P^\ast \otimes_R Q & \rightarrowtail & (R^n)^\ast \otimes_R Q \\
\downarrow \cong & & \downarrow \phi_Q & & \downarrow \cong \\
\hom_R(R^n, Q) & \twoheadrightarrow & \hom_R(P, Q) & \rightarrowtail & \hom_R(R^n, Q)
\end{array}$$
where both rows are image factorizations of idempotent maps induced by $e$, and the vertical maps on the boundaries are clearly isomorphisms (by canonically identifying their domains and codomains with $Q^n$). Now $\phi_Q$ is epic because its composition with the top left arrow is epic, and $\phi_P$ is monic because its composition with the bottom right arrow is monic. Being monic and epic, $\phi_Q$ is an isomorphism. $\Box$
It can't be literally correct that we "picked a basis" (of $P$) in order to describe the trace on $\hom_R(P, P)$. The most we did is exploit one of the definitions of f.g. projective module, involving images of idempotent matrices $e$, in order to validate the claim that the natural map $\phi_P$ is invertible (what we did is show that its relational opposite $(\phi_P)^{-1}$ is a well-defined function).
So if you like, you can view trace as defined above initially as a relational composite $\mathrm{ev} \circ (\phi_P)^{op}$, and then verify as we did that the relation you get this way is in fact a well-defined function.
Just a few more remarks: the first comment I made under the original post was [in retrospect!] a kind of response to Timothy's comment to Andrej Bauer: "Right, that's why I was hoping for something along the lines of, setting up axioms that capture most of linear algebra, but where "finite-dimensional" vector spaces don't necessarily have a basis." The idea I had is that we generalize from ordinary linear algebra over a field $k$ to linear algebra over slightly more general sorts of rings $R$, where we might not have the luxury that finitely generated $R$-modules have bases, thus forcing us to do things differently.
So, if for example $R$ (again commutative) is a Noetherian von Neumann regular ring, then those are sufficient to guarantee that any finitely generated module is in fact finitely generated projective, and then set up trace as above. I think readers will be able to figure this out mostly on their own, perhaps with a few hints: (1) the Noetherian assumption is used to ensure that finitely generated modules are finitely presentable, and (2) finitely presentable modules over a von Neumann regular ring are projective; this uses some of the lore of von Neumann regular rings, which you can find in the nLab article on vN regular rings, particularly lemmas 2.3 and 2.4 (see there). Of course, commutative vN regular rings are not exactly a huge departure from the comfort of fields!