I got interested in the question because we did once win a sefer Torah at such a raffle during a tsedaka dinner for a school. It was organized by an organization run by a well-respected and very knowledgeable rav and no one raised halachik issues.
Your question got me thinking. I found an interesting source on the topic. dinonline writes
Panim Me’iros (3:43) writes relates to a case in which a person went
broke and lost all his possessions save a sefer Torah, which he needed
to sell in order to marry off a daughter. After unsuccessfully trying
to find buyers, he decided to try a lottery. Panim Me’iros writes that
this is permitted, because it is for the benefit of the Torah, which
currently has no buyers. This answer is quoted by Atzei Chaim (YD 30).
However, Zera Avraham (YD 7) writes that the practice is prohibited,
comparing the sale by means of a lotterty to the disrespectful sale of
the meat of a firstborn animal (which is prohibited). Tzitz Eliezer
(vol. 22, no. 50) adds that Chacham Tzvi (123) prohibits the sale of a
sefer Torah by means of an auction, and compares an auction to a
lottery (though there is room to debate the comparison).
He concludes that the the lottery is not respectful. However, for the
purpose of a mitzvah (which includes raising necessary funds for a
shul), one can rely on the opinions above that permit the practice.
Since I don't like the idea of storing the sefer Torah in a shul that already has many, I lent it to a wonderful organization that builds synagogues in previously secular kibbutzim where there is new interest in yiddishkeit. The sefer Torah allows them full shabbat and yom tov services and it is used all the time