_Problem:_ Given Newton's second law $$\tag{1} m\ddot{q}^j~=~-\beta\dot{q}^j-\frac{\partial V(q,t)}{\partial q^j}, \qquad j~\in~\{1,\ldots, n\}, $$ for a non-relativistic point particle in $n$ dimensions, subjected to a friction force, and also subjected to various forces that have a total potential $V(q,t)$, which may depend explicitly on time. I) _Conventional approach:_ There is a non-variational formulation of Lagrange equations $$\tag{2} \frac{d}{dt} \left(\frac{\partial L}{\partial \dot{q}^j}\right)-\frac{\partial L}{\partial q^j}~=~Q_j, \qquad j~\in~\{1,\ldots, n\},$$ where $Q_j$ are the generalized forces that do not have generalized potentials. In our case (1), the Lagrangian in eq. (2) is $L=T-V$, with $T=\frac{1}{2}m\dot{q}^2$; and the force $$\tag{3} Q_j~=~-\beta\dot{q}^j$$ is the friction force. It is shown in e.g. [this](https://physics.stackexchange.com/q/20929/2451) Phys.SE post that the friction force (3) does not have a potential. As OP mentions, one may introduce the [Rayleigh dissipative function](http://en.wikipedia.org/wiki/Rayleigh_dissipation_function), but this is not a genuine potential. Conventionally, we additionally demand that the Lagrangian is of the form $L=T-U$, where $T=\frac{1}{2}m\dot{q}^2$ is related to the LHS of EOM (1) (i.e. the kinematic side), while the potential $U$ is related to the RHS of EOM (1) (i.e. the dynamical side). With these additional requirements, the EOM (1) does not have a variational formulation of Lagrange equations $$\tag{4} \frac{d}{dt} \left(\frac{\partial L}{\partial \dot{q}^j}\right)-\frac{\partial L}{\partial q^j}~=~0,\qquad j~\in~\{1,\ldots, n\}, $$ i.e. [Euler-Lagrange equations](http://en.wikipedia.org/wiki/Euler%E2%80%93Lagrange_equation). The Legendre transformation to the Hamiltonian formulation is traditionally only defined for a variational formulation (4). So there is _no_ conventional Hamiltonian formulation of the EOM (1). II) _Unconventional approach$^1$:_ Define for later convenience the function $$\tag{5} e(t)~:=~\exp(\frac{\beta t}{m}). $$ A possible variational formulation (4) of Lagrange equations is then given by the Lagrangian $$\tag{6} L(q,\dot{q},t)~:=~e(t)L_0(q,\dot{q},t), \qquad L_0(q,\dot{q},t)~:=~\frac{m}{2}\dot{q}^2-V(q,t).$$ The corresponding Hamiltonian is $$\tag{7} H(q,p,t)~:=~\frac{p^2}{2me(t)}+e(t)V(q,t).$$ One caveat is that the Hamiltonian (7) does not represent the traditional notion of total energy. Another caveat is that this unconventional approach cannot be generalized to the case where two coupled sectors of the theory require different factors (5), e.g. where each coordinate $q^j$ has individual friction-over-mass-ratios $\frac{\beta_j}{m_j}$, $j\in\{1, \ldots, n\}$. For this unconventional approach to work, it is crucial that the factor (5) is an overall common multiplicative factor for the Lagrangian (6). This is an unnatural requirement from a physics perspective. -- $^1$ Hat tip: [Valter Moretti](https://physics.stackexchange.com/a/89395/2451).