First of all, it is to be borne in mind that Islam came to liberate the mind from superstition and error. In this context, Islam places the human mind in a frame of religious texts that prevent it from falling into error. What is being circulated among people that a ghost appears in a scene of crime or the like has no basis in Shari`ah. It is even impermissible to believe in such things.
Addressing this point in detail, late Sheikh Hasanein Makhlouf, former Mufti of Egypt, may Allah bless his soul, states the following: Such sayings have no basis in Shari`ah and are no more than superstitions. In the pre-Islamic period, Arabs used to believe that the souls of the dead and their decayed bones depart and turn into a bird that flies high in the sky. They used to give it the name ‘Hamah’ or ‘Sada’. The Arab poet Lubaid says:
“After your passing away, no men are there sure.
All people are ‘Ham’ (sing. ‘Hamah’) no more.”
Among their fake beliefs was that the soul of a murdered stand by the grave saying: ‘I am thirsty! I am thirsty!’. They believed that it would not rest in peace until after the family of the murdered avenged his killing. This was a natural outcome of the ignorance they felt in their hearts and the traditions and customs prevailing at that time.
The advent of Islam put an end to such fake beliefs and baseless ideas. The glowing sun of Islam melted away the clouds of these dark beliefs that befogged the minds of people for ages. The Prophet, peace and blessings be upon him, in many instances made it clear that such sayings and beliefs have no basis. He clarified that the minds should be purified from such murky thoughts.
Thus, the common idea of having a dead person appear in form of a ghost traces back to the false beliefs of the pre-Islamic era of ignorance. It is thus Islamically rejected to lend an ear to such things, let alone to believe in it. As we know that after death a person enters into a different world known as Alam Al-Barzakh, preparing to account for all his deeds. It’s a place in transition before the coming of the Day of Reckoning. So, it would be hard to believe that such a person would have time to roam about in the world of the living.