I believe the general problem (i.e. in the non-finite case) is still an open problem. In Pitts' 1992 On an Interpretation of Second Order Quantification in First Order Intuitionistic
Propositional Logic, it is written:
The results presented in this paper have had a rather long gestation period. Some ten or so years ago I tried to prove the negation of Theorem 1 in connection with the higher order analogue of Proposition 18- the question of whether any Heyting algebra can appear as the algebra of truth-values of an elementary topos. [...] It remains an open question whether every Heyting algebra can be the Lindenbaum algebra of a theory in intuitionistic higher order logic.
Some special cases are known. For instance, it is known (e.g. p. 332 of Johnstone's 1977 Topos theory) that the statement is true for every Boolean algebra (the construction therein is attributed to Freyd).
Recently, Kuznetsov gave a talk entitled On Boolean Topos Constructions by Freyd and Pataraia and their generalizations at TACL 2024, proposing a generalisation of this result, but suggesting the general problem is still open.