Did Hophni and Phinehas believe in God?
Hophni and Phinehas were two sons of Eli, the high priest of God (I Samuel 1:3). They served as priests at the tabernacle. But despite their position, they were wicked. "Now Eli was very old; and he heard everything his sons did to all Israel, and how they lay with the women who assembled at the door of the tabernacle of meeting" (I Samuel 2:22).
Eli scolded them, but he would not take action against them. "So he said to them, "Why do you do such things? For I hear of your evil dealings from all the people. No, my sons! For it is not a good report that I hear. You make the LORD'S people transgress. If one man sins against another, God will judge him. But if a man sins against the LORD, who will intercede for him?" Nevertheless they did not heed the voice of their father, because the LORD desired to kill them" (I Samuel 2:23-25). Because Eli refused to uphold the Law of God against his own sons, tragedy came to the house of Eli.
"Therefore the LORD God of Israel says: 'I said indeed that your house and the house of your father would walk before Me forever.' But now the LORD says: 'Far be it from Me; for those who honor Me I will honor, and those who despise Me shall be lightly esteemed. Behold, the days are coming that I will cut off your arm and the arm of your father's house, so that there will not be an old man in your house. And you will see an enemy in My dwelling place, despite all the good which God does for Israel. And there shall not be an old man in your house forever. But any of your men whom I do not cut off from My altar shall consume your eyes and grieve your heart. And all the descendants of your house shall die in the flower of their age. Now this shall be a sign to you that will come upon your two sons, on Hophni and Phinehas: in one day they shall die, both of them. 'Then I will raise up for Myself a faithful priest who shall do according to what is in My heart and in My mind. I will build him a sure house, and he shall walk before My anointed forever'" (I Samuel 2:30-35).
God's promise was fulfilled when He allowed the Ark of the Covenant to be captured. Hophni and Phinehas, who had accompanied the ark were slain in the battle (I Samuel 4:11). When Eli heard the news, he fainted, broke his neck and died as well (I Samuel 4:17).
But you asked if Hophni and Phinehas believed in God. The Bible doesn't record an answer to that question. We cannot assume, just because they were wicked, that they did not believe in God. After all, "You believe that there is one God. You do well. Even the demons believe--and tremble!" (James 2:19). It is possible for a person to believe, but not to act on that belief. The two sons of Eli did accompany the ark into battle (I Samuel 4:4), so it appears they thought its presence would do something, but what they expected we do not know.