For LuaTeX here is an implementation of David Carlisles idea to create a hypenate callback. It works by replacing every ſ with a marked s before hyphenation and then recovering the original characters after hyphenation:
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{luacode}
\begin{luacode*}
local sattr = luatexbase.new_attribute("longsattr")
local disc = node.id'disc'
print('DISC', disc)
local function long_to_s(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
print(n)
long_to_s(n.pre)
long_to_s(n.post)
long_to_s(n.replace)
end
if n.char == 383 then
n.char = 115
node.set_attribute(n, sattr, 383)
end
end
end
local function s_to_long(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
s_to_long(n.pre)
s_to_long(n.post)
s_to_long(n.replace)
end
local a = node.get_attribute(n, sattr)
if a then
n.char = a
node.unset_attribute(n, sattr)
end
end
end
local function myhyph(head, tail)
long_to_s(head, tail)
lang.hyphenate(head, tail)
s_to_long(head, tail)
end
luatexbase.add_to_callback("hyphenate",myhyph,"hyphenate with modified s")
\end{luacode*}
\begin{document}
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft
XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
\end{document}

LuaTeX also allows you to manipulate the hyphenation pattern during a run, so you can also use (this is an automated version of David Carlisles choice (b)):
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{luacode}
\begin{luacode*}
local l = lang.new(tex.language)
l:patterns(l:patterns():gsub('s', 'ſ'))
\end{luacode*}
\begin{document}
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft
XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
\end{document}

\patternsor\hyphenation– David Carlisle Aug 06 '18 at 14:45\hyphenationas you have done for all necessary words or (b) copy the hyphenation patterns adding patterns for long s to match those for s and rebuild the xelatex format (lulatex does not need to be rebuilt) or (c) usesin the original markup and then set up font features (perhaps...) so that some s get typeset using the long form. Which would you prefer? (the last probably depends on the font you use) – David Carlisle Aug 06 '18 at 15:29\babelpatternsin the document itself. – Javier Bezos Aug 06 '18 at 17:38