Do you have specific examples of Marxists whose "hostility" to religion can be compared to Marx's approach?
Marx himself was not "outright" hostile to religion in the way you may be thinking of because he did see value in self-identifying as an atheist, but rather held the view that the criticism of religion during his time was already complete, and that religion had been exposed as a lie that only persisted because the material conditions that gave rise to it were still prevalent.
For Germany, the criticism of religion has been essentially completed, and the criticism of religion is the prerequisite of all criticism.
The profane existence of error is compromised as soon as its heavenly oratio pro aris et focis [“speech for the altars and hearths,” i.e., for God and country] has been refuted. Man, who has found only the reflection of himself in the fantastic reality of heaven, where he sought a superman, will no longer feel disposed to find the mere appearance of himself, the non-man [Unmensch], where he seeks and must seek his true reality.
The foundation of irreligious criticism is: Man makes religion, religion does not make man. Religion is, indeed, the self-consciousness and self-esteem of man who has either not yet won through to himself, or has already lost himself again. But man is no abstract being squatting outside the world. Man is the world of man – state, society. This state and this society produce religion, which is an inverted consciousness of the world, because they are an inverted world. Religion is the general theory of this world, its encyclopaedic compendium, its logic in popular form, its spiritual point d’honneur, its enthusiasm, its moral sanction, its solemn complement, and its universal basis of consolation and justification. It is the fantastic realization of the human essence since the human essence has not acquired any true reality. The struggle against religion is, therefore, indirectly the struggle against that world whose spiritual aroma is religion.
A Contribution to the Critique of Hegel’s Philosophy of Right, Karl Marx
One reason that he did not engage in the atheistic discourse of his day was that he viewed it as an idealistic rather than a materialistic position, as he mentions when he criticizes "atheistic philanthropy".
Communism begins from the outset with atheism; but atheism is at first far from being communism; indeed, that atheism is still mostly an abstraction.
The philanthropy of atheism is therefore at first only philosophical, abstract philanthropy, and that of communism is at once real and directly bent on action.
Here we see that to Marx, a rejection of religion as an answer to how the world works is a prerequisite to being a communist.
And in this passage he more clearly outlines that a socialistic/materialistic framework makes it impossible to accept the existence of a being alien to man (God), while also outlining why he believes atheism to itself an abstraction by defining the existence of man through a negation.
Since the real existence of man and nature has become evident in practice, through sense experience, because man has thus become evident for man as the being of nature, and nature for man as the being of man, the question about an alien being, about a being above nature and man – a question which implies the admission of the unreality of nature and of man – has become impossible in practice. Atheism, as the denial of this unreality, has no longer any meaning, for atheism is a negation of God, and postulates the existence of man through this negation; but socialism as socialism no longer stands in any need of such a mediation. It proceeds from the theoretically and practically sensuous consciousness of man and of nature as the essence. Socialism is man’s positive self-consciousness, no longer mediated through the abolition of religion, just as real life is man’s positive reality, no longer mediated through the abolition of private property, through communism. Communism is the position as the negation of the negation, and is hence the actual phase necessary for the next stage of historical development in the process of human emancipation and rehabilitation. Communism is the necessary form and the dynamic principle of the immediate future, but communism as such is not the goal of human development, the form of human society.
Economic and Philosophic Manuscripts of 1844, Karl Marx
My familiarity with Marx extends mostly through his economic writings, specifically in the way that it influenced U.S. Foreign Policy. That being said, Marx (and his reviewer Frederick Engels) discuss religion once each in A Contribution to the Critique of Political Economy.
The first refers to Marx's opinion on hoarding wealth. With his desire that social wealth be equally distributed, Marx cites Protestants (with Puritan tendencies) as "hoarders of money [combining] asceticism with assiduous diligence." (p130) Marx also discusses the practice of "non-Moslem heathens" as guilty of the same action of burying their wealth to withdraw money from circulation. His opinion was that the auri sacra fames or lust for gold was the root of the evil of exchange-value. The more a person hoarded worth "in its social form" Marx considers barbaric and connects directly to a necessary root for Capitalism. Of course, Marx's opinion on capital hoarded like this was linked directly to gold and silver which is viewed as irrelevant in today's intangible state-backed dollar bill.
More specifically for your question, Marx did not agree with religious tendencies to accumulate wealth as religion = Capitalism under this theory.
Engels' review (p 218-220) discusses religion only once here as well. The idea of the German political economy emerging from the proletarian party is the "materialist conception of history."
More specifically he states
The proposition that "the process of social, political and >intellectual life is altogether necessitated by the mode of >production of material life"; that all social and political relations, >all religious and legal systems, all theoretical conceptions which >arise in the course of history can only be understood of the >material conditions of life obtaining during the relevant epoch >have been understood and the former are traced back to these >material conditions, was a revolutionary discovery not only for the >economics but also for all historical sciences--and all branches of >science which are not natural sciences are historical."
In summary; religious criticism doesn't enter the picture until we understand the material conditions in which life exists. Marx's very heavy theory (especially for such a short book) bases that economic value of a peoples is more important than religious opinions.
Source: Marx, Karl. A Contribution to the Critique of Political Economy. USSR: Lawrence and Wisehart, 1971.
Karl Marx wasn't as outright hostile towards religion as many inspired by him.
OP really needs to elaborate on this claim and the question itself. What qualifies as "outright hostile towards religion" if not the sentence "religion is opium of the people" as it is worded in the Communist Manifesto?