Short answer
Not according to most Hanafi muftis. Donating your whole body for dissection or research delays or prevents burial and breaches the honour of the dead, which the Prophet ﷺ compared to harming the living. Some contemporary scholars allow dissection for training doctors under conditions, but they do not encourage Muslims to bequeath their own bodies. Ask a mufti before signing anything.
Bequeathing one's body for dissection or research is not permitted on the relied-upon view of Deobandi and traditional Hanafi muftis, because the body is a trust and not property, the dead keep their honour, and prompt washing and burial are a communal obligation. Such a bequest does not bind the heirs.
The four schools agree on this.
Explanation
Allah says We have certainly honoured the children of Adam (17:70), and that honour continues after death. The Prophet ﷺ said that breaking the bone of a dead person is like breaking it while they are alive. Washing, shrouding, praying over and promptly burying the dead is a communal obligation (fard kifayah), and whole-body donation usually means the body is kept for months or years, and parts of it may never be buried.
For these reasons most Hanafi muftis hold that a Muslim may not donate their body to a medical school or research programme, and that a will to do so has no force: a will can only dispose of what you own, for a lawful purpose, and your body is a trust from Allah. The family should arrange the janazah and burial as normal.
Other scholars allow dissection of bodies to train doctors, because medical education serves a real public need, and they set conditions such as respect for the body and burial of all its parts afterwards. Even on that view, Muslims are not urged to give their own bodies, and models and simulation are preferred where they serve. The difference is among contemporary scholars, not among the four classical schools.
If you want your death to benefit others, there are other ways: leaving up to a third of your wealth to medical charities in your will, giving blood in your lifetime, and, if you follow the scholars who allow it, organ donation (see is organ donation haram). For post-mortems required by law, see is an autopsy allowed.
Ask a mufti about your own case. This answer explains the general ruling. When the details of your situation matter, as they do here, ask a qualified mufti and give them the full facts. Where to ask a scholar.
The evidence
Quran, Surah Al-Israa 17:70
۞ وَلَقَدْ كَرَّمْنَا بَنِىٓ ءَادَمَ وَحَمَلْنَٰهُمْ فِى ٱلْبَرِّ وَٱلْبَحْرِ وَرَزَقْنَٰهُم مِّنَ ٱلطَّيِّبَٰتِ وَفَضَّلْنَٰهُمْ عَلَىٰ كَثِيرٍۢ مِّمَّنْ خَلَقْنَا تَفْضِيلًۭا ﴿٧٠﴾
And We have certainly honored the children of Adam and carried them on the land and sea and provided for them of the good things and preferred them over much of what We have created, with [definite] preference.
Human dignity remains after death.
Sunan Abi Dawud 3207
Graded sahih... كسر عظم الميت ككسره حيا ...
"Breaking the bone of a dead person is like breaking it while alive."
The body of the dead must be treated with respect.
Where the ruling is recorded
- Jawahir al-Fiqh (Mufti Muhammad Shafi), Treatise on human organ transplantation. Holds that a person does not own their body and may not give it away.
- al-Hidaya, Kitab al-Wasaya. A bequest is valid only in what the testator owns and for a lawful purpose.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.