I have a long sanskrit compound taking up almost a line, but leaving a small space at the right margin empty, too small for the first syllable of the next word, thus breaking the justified alignment. See example in footnote 1. Taking inspiration from this question I did some experiments with the soul package, with an almost satisfying result, see footnote 2, but the word's last letter disappeared.
MWE:
\documentclass{memoir}
\usepackage{soul}
\usepackage{calc}
\usepackage{fontspec}
\setlength{\footmarkwidth}{\leftmargin}
\setlength{\footmarksep}{0em}
\footmarkstyle{#1\hfill}
\sodef\spaceout{}{0em plus 1fil}{0em plus 1fil}{0em plus 1fil}
\begin{document}
\footnote{aśeṣavācyavācakātmakajagadabhedacamatkārātmakaśabdarāśivimarśaparamārthā sar\-vamantrāraṇis tatra tatrāgameṣu nirdiśyate | sā caiṣā viśvāvamarśanena paraṃ jñānaṃ prayacchati.}
\footnote{\makebox[\textwidth-\footmarkwidth][l]{\spaceout{aśeṣavācyavācakātmakajagadabhedacamatkārātmakaśabdarāśivimarśaparamārthā}} sar\-vamantrāraṇis tatra tatrāgameṣu nirdiśyate | sā caiṣā viśvāvamarśanena paraṃ jñānaṃ prayacchati.}
\end{document}

EDIT: This question seems related. Adding the three lines
\makeatletter
\sbox0{\ttfamily\global\let\SOUL@tt\ttfamily}
\makeatother
to circumvent soul's choice of a font not containing the necessary diacritical combinations brings me a bit closer to a solution, the ā is preserved, but I get a ! Package soul Error: Reconstruction failed. and the following output containing a small black box:
. Obviously soul tries to hyphenate the long word (which it shouldn't do) and fails to do so.
