You may find the responses on this thread interesting: Fitting external models with Stan
Depending on how complicated the density is, you may be able to code it in Stan, but usually this question comes up when the density depends on some expensive, complicated, or implemented-in-Fortran-by-someone-else calculation, in which case using Stan directly becomes more difficult