Your best bet is to use the fontspec package to use a suitable Devanagari Unicode font.
\usepackage{fontspec}
\newfontfamily{\SA}[Script=Devanagari]{Sanskrit2003}
It is then simply a matter of putting in the Devanagari. The way you do that is really off-topic here! I used a Devanagari keyboard layout:
\documentclass{article}
\usepackage[parfill]{parskip}
\usepackage{fontspec}
\newfontfamily{\SA}[Script=Devanagari]{Sanskrit2003}
\begin{document}
{\SA कर्मण्येवाधिकारस्ते मा फलेषु कदाचन~। \\
मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि~॥~४७~॥}
\end{document}

The ~s in the Sanskrit are just non-breaking spaces to make sure that no line is broken before the daṇḍa or the double daṇḍas or anything.
Karmaṇy evādhikāras te mā phaleṣu kadācana; Mā karmaphalahetur bhūr mā te saṅgo'stv akarmaṇi.
– Au101 Apr 08 '17 at 00:29