Technically, yes, but only in certain circumstances.
Generally, Muslims should be buried directly in the soil, with nothing separating them from the ground. That’s because, in the Islamic belief, humans are created from soil, to which they’ll return and from which they’ll be resurrected.
So, even if the deceased left in his will that he’d like to be buried in a coffin, his family should not obey his wishes.
Still, there are certain conditions where using a coffin is necessary.
The first is when the ground is too soft, dewy, and loose. A coffin here is permitted to avoid the collapse of the ground on the deceased.
The same applies if the deceased body is too worn-out or destroyed, say from a fire or a cave-in. Here, a coffin may be the only thing that’s keeping the body whole, protecting it during the burial process.
Finally, if there’s a fear of animals digging up the grave and eating the body, a coffin can be used to protect the body.
Other than those three cases, it’s prohibited to bury a Muslim in a coffin.
After the body has been properly washed, shrouded, and prayed upon, it’s taken to the graveyard. There, the deceased is lowered in the prepared grave, which should always point in the direction of the Qibla (the city of Mecca).
After the deceased has been settled in the grave and positioned appropriately, wooden boards are placed atop him. These boards will act as a barrier, shielding the deceased from the dirt as the buriers cover his body.
As the body is getting buried, verses from the Quran are recited, and prayers are said, asking for the forgiveness of the deceased, as well as all the Muslim dead.