I'm not sure why you want to do that way; however, you can specify an NFSS family name corresponding to \codefont:
\newfontfamily\codefont[
NFSSFamily=Inconsolata,
Scale=MatchLowercase,
Path = fonts/
]{Inconsolata-dz}
\renewcommand{\ttdefault}{Inconsolata}
Full test, where I used Inconsolatazi4 and commented the Path line.
\documentclass{article}
\usepackage{fontspec}
\newfontfamily\codefont[
NFSSFamily=Inconsolata,
Scale=MatchLowercase,
% Path = fonts/
]{Inconsolatazi4}
\renewcommand{\ttdefault}{Inconsolata}
\begin{document}
This should be Inconsolata: {\codefont Test of mono font}
This should be Inconsolata: \texttt{Test of mono font}
\end{document}
