There are three views on the legal punishment for Bestiality in Shariah:
There is a Hadd for it: the offender (be they married or unmarried) will be killed. This is based on the following hadith from the Prophet:
من وقع على بهيمة فاقتلوه واقتلوا البهيمة
Whoever copulates with an animal, kill him and kill the animal.
Abu Daud, Ibn Majah, Tirmizi
This is also the law of the Torah (Exodus 22:18/19 and Leviticus 20:15). Scholars supporting this also make an analogy with sodomy based on Quran 7:80-81. This is one of the views of the Shafi'is and one of the views of the Hanbalis.
The Hadd of Zina applies. A muhsan (married) offender will be stoned to death (Rajm) while an un-married offender will be whipped 100 lashes. This is based on the reasoning that Bestiality resembles and is analogous to Zina: private parts meet and interact, fluid is exchanged and desire is gratified.
An unmarried offender will not be executed because of the well known hadith of the Prophet:
لا يحل دم امري مسلم يشهد ان لا اله الا الله واني رسول الله الا باحدى ثلاث النفس بالنفس والثيب الزاني، والمارق من الدين التارك الجماعة
The blood of a Muslim ... cannot be shed except in three cases:
i) In Qisas (retaliation) for murder,
ii) a married person who commits illegal sexual intercourse and
iii) the one who reverts from Islam (apostate) and leaves the Muslims
Sahih Bukhari
This is one of the view of the Shafi'is. It is a view of the Malikis according to الفقه على المذاهب الأربعة but I couldn't find corroboration in the few other texts that I read.
A Tazir punishment is obligatory on the the judge but not a Hadd, because, they argue:
There is no clear evidence that there is a Hadd for it. The first hadith is disputed and there is a contradictory report from the narrator Ibn Abbas, who is also reported to have said:
ليس على الذي ياتي البهيمة حد
There is no Hadd for one who has sexual intercourse with an animal.
Abu Daud
Bestiality is different from Zina: It does not come under the dictionary definition of Zina. It does not lead to repercussions for others like defiling another human's honor or conception of an illegitimate child. It is not enticing or tempting to the heart but rather considered repulsive and abominable.
If there is no Hadd punishment on it then a Ta'zir punishment applies. That is because bestiality is haram (23:5-7) and there is Ijma' on its prohibition:
واتفقوا على أن إتيان البهائم حرام
And it is agreed upon that bestiality is haram
— Iqnaa‘ fi Masaa’il al-Ijmaa‘
And a Ta'zir is prescribed for every sin which does not have a Hadd punishment - since we have been commanded to change wrongdoing with our hands (i.e. using strength), and this too is agreed upon:
أجمع العلماء على أن التعزير مشروع في كل معصية لا حد فيها ولا كفارة
The scholars have a consensus that Ta'zir is prescribed for every sin for which there is no Hadd or Kaffarah.
— Majmoo‘ al-Fataawa
The nature and severity of a Tazir is left to the Qadi (judge), he may choose a punishment that he feels is appropriate and adequate to act as a deterrence on a case by case basis. Punishments may include imprisonment, chastisement, lashes (must be less in number than in Hudood) etc. A repeated offender or one who considers it lawful may be executed.
This is the view of the Hanafis, one of the views of the Shafi'is, Hanbalis and Malikis. And this is the majority view.
Below I am providing my personal translation of some relevant Fiqh texts:
The views of the Sunni Madhabs as related in الفقه على المذاهب الأربعة:
الحنفية - قالوا: لا حد في هذه الفاحشة حيث إنه لم يرد شيء عن ذلك في كتاب الله تعالى ولا في سنة رسوله صلوات الله وسلامه عليه. ولم يثبت ان الرسول صلى الله عليه وسلم أقام الحد على من وقع في هذه الفاحشة. ولكن يجب عليه التعزير بما يراه الحاكم، من الحبس أو الضرب أو التوبيخ أو غير ذلك مما يكون زاجراً له ولغيره، عن ارتكابه.
The Hanafis say there is no Hadd for this lewd sin. There is no mention of a legal punishment in the Book of Allah or the Sunnah of the Prophet of Allah, nor is it proven that the Prophet enforced a Hadd on a doer of this deed. But it is wajib on the Ruler that according to his opinion he should give whatever punishment. He may imprison, or whip or chastise such that it would provide deterrence.
المالكية - قالوا: إن حده كحد الزنا، فيلج البكر، ويرجم المحصن، وذلك
لأنه نكاح فرج محرم شرعاً مشتهى طبعاً، مثل القبل، والدبر، فأوجب الحد
كالزنا.
The Malikis say: the punishment of this action is the same as Zina.
The unmarried adult would be whipped and the mohsan would be stoned. [
similarity to Zina as explained above ]
الشافعية - قالوا: عندهم ثلاثة آراء: أهرها، الحد كما قال المالكية،
فحكمه مثل الزنا, القول الثاني: إنه يقتل بكراً، أو ثيباً، وذلك لما روي
عن الرسول صلوات الله وسلامه عليه أنه قال: (منوقع على بهيمة فاقتلوهن
واقتلوا البهيمة) رواه غلإمام أحمد، وأبو داود، والترمذي عن أبن عباس رقد
روى هذا الحديث أبن ماجة في سننه، من حديث إبراهيم بن اسماعيل عن داود بن
الحصين عن عكرمة، عن أبن عباس أن رسول الله صلى الله عليه وسلم قال: (من
وقع على ذات محرم فاقتلوه، ومن وقع على بهيمة فاقتله، واقتلوا البهيمة) .
القول الثالث: إنه يعزر، ولا حد فيه، حسب ما يراه الإمام موافقة لمذهب
الحنفية.
The Shafi'is say they have three opinions, the most correct of which is
that the person would get the Hadd as the Malikis say, that the ruling
is similar to that of Zina.
The Second saying is that this person, married or unmarried, should be
killed because [ first hadith quoted above and its narrators and works
recording it]
The Third saying is that the person should be punished with Tazir, as
is the opinion of Abu Hanifa
الحنابلة - قالوا: يجب عليه الحد، وفي صفة الحد عندهم روايتان، إحداهما
كاللواطة وثانيهما أنه يعزر، وهو الراجح عندهم، مثل قول الحنفية.
The Hanbalis say that the Hadd is wajib and there are two opinions
about its nature. First, that the Hadd of homosexual sodomy should be
enforced on them. The second is that they should be given Tazir
punishment. And the opinion that is preferred among them is (the second
one) that is similar to the view of the Hanafis.
Tafsir Qurtubi on 7:80:
الثالثة : فإن أتى بهيمة فقد قيل : لا يقتل هو ولا البهيمة
. وقيل : يقتلان ; حكاه ابن المنذر عن أبي سلمة بن عبد الرحمن . وفي
الباب حديث رواه أبو داود والدارقطني عن ابن عباس قال قال رسول الله صلى
الله عليه وسلم : من وقع على بهيمة فاقتلوه واقتلوا البهيمة معه . فقلنا
لابن عباس : ما شأن البهيمة ؟ قال : ما أراه قال ذلك ، إلا أنه كره أن
يؤكل لحمها وقد عمل بها ذلك العمل . قال ابن المنذر : إن يك الحديث ثابتا
فالقول به يجب ، وإن لم يثبت فليستغفر الله من فعل ذلك كثيرا ، وإن عزره
الحاكم كان حسنا . والله أعلم .
وقد قيل : إن قتل البهيمة لئلا تلقي خلقا مشوها ; فيكون قتلها مصلحة
لهذا المعنى مع ما جاء من السنة . والله أعلم . وقد روى أبو داود عن ابن
عباس قال : ليس على الذي زنى بالبهيمة حد . قال أبو داود : وكذا قال عطاء
. وقال الحكم : أرى أن يجلد ولا يبلغ به الحد . وقال الحسن : هو بمنزلة
الزاني . وقال الزهري : يجلد مائة أحصن أو لم يحصن .
وقال مالك والثوري وأحمد وأصحاب الرأي يعزر . وروي عن عطاء والنخعي
والحكم . واختلفت الرواية عن الشافعي ، وهذا أشبه على مذهبه في هذا الباب
. وقال جابر بن زيد : يقام عليه الحد ، إلا أن تكون البهيمة له
If someone came to an animal then about it has been said that neither
the man would be killed nor the animal.
And there is also a saying that: both shall be killed. This has been
narrated by Ibn Mundhir from Abu Salmah bin Abdur Rehman. And on this
topic is also another hadith which Abu Daud has narrated from Ibn
Abbas "the one lays with an animal, then kill him and also kill the
animal" ... Ibn Mundhir said: If this Hadith is proven then acting
according to it is obligatory, and if not then the person should
repent in front of Allah and the Ruler should enforce Tazir on him.
And Allah knows best.
And it has been said that the command to kill the animal is so that no
abomination should be born of it ... Abu Daud narrated from Ibn Abbas
that a person who copulates with an animal, Hadd will not be enforced
on him. Abu Daud said: Ata said the same. And Hakam said: My opinion is
that he should be whipped with lashes but they should not reach the
number as in a Hadd. And Hassan said: He is similar to the case of a
Zani (adulterer\fornicator). And Zuhri said: He should be whipped with
100 lashes, be he married or unmarried.
Malik, Thawri, Ahmad and the Ashab al-Ra'y (Hanafis) had the opinion: He should be
given a Tazir. This is narrated from Ata, Nakha‘i and Hakam. From Shafi'i
one narration is different from this, and that is closer to his madhab
...
Tafsir Jassas on Surah Nur:
الذي يأتي البهيمة الذي يأتي البهيمة قال أبو حنيفة وأبو يوسف وزفر ومحمد
ومالك وعثمان البتي : " لا حد عليه ويعزر " .
وروي مثله عن ابن عمر . وقال الأوزاعي : " عليه الحد " . قال أبو بكر :
قوله صلى الله عليه وسلم : لا يحل دم امرئ مسلم إلا بإحدى ثلاث زنا بعد
إحصان وكفر بعد إيمان وقتل نفس بغير نفس ينفي قتل فاعل ذلك ؛ إذ ليس ذلك
بزنا في اللغة ، ولا يجوز إثبات الحدود إلا من طريق التوقيف أو الاتفاق ،
وذلك معدوم في مسألتنا ، ولا يجوز إثباته من طريق المقاييس . وقد روى
عمرو بن أبي عمرو عن عكرمة عن ابن عباس قال : قال رسول الله صلى الله
عليه وسلم : من وجدتموه على بهيمة فاقتلوه واقتلوا البهيمة ، وعمرو هذا
ضعيف لا تثبت به حجة . ومع ذلك فقد روى شعبة وسفيان وأبو عوانة عن عاصم
عن أبي رزين عن ابن عباس فيمن أتى بهيمة : " أنه لا حد عليه " ، وكذلك
رواه إسرائيل وأبو بكر بن عياش وأبو الأحوص وشريك كلهم عن عاصم عن أبي
رزين عن ابن عباس مثله ، ولو كان حديث عمرو بن أبي عمرو ثابتا لما خالفه
ابن عباس وهو راويه إلى غيره ، وإن صح الخبر كان محمولا على من استحله
A man who has intercourse with an animal:
Imam Abu Hanifa, Imam Abu Yusuf, Imam Muhammad, Imam Malik and
Uthman's saying is that such a person would be given Tazir punishment
and a Hadd will not be enforced. The same is narrated from Ibn Umar.
Awzai's saying is that the Hadd will be enforced on him.
Abu Bakr Jasas says that the Prophet's saying:
The blood of a Muslim ... cannot be shed except in three cases:
i) In Qisas (retaliation) for murder, ii) a married person who
commits illegal sexual intercourse and iii) the one who reverts from
Islam (apostate) and leaves the Muslims
negates the action of killing a person for this deed, because
according to a dictionary this action is not called Zina, nor is it
valid to make analogy of it with it.
[narration chain] narrated from Ibn Abbas that the Prophet said:
"Whoever copulates with an animal, kill him and kill the animal."
The narrator of this tradition, 'Amr b. Abi 'Amr is weak and no
evidence can be based on his narration.
With this, there is also the narration:
[narration chain]
"There is no Hadd for one who has sexual intercourse with an animal."
If the first narration is correct then Ibn Abbas would not have
narrated against it.
However, even if it is proven that the (first) narration is correct we
would interpret that it applies when a person does it while considering his action to be
lawful (i.e. is an apostate)
Further also see وطء البهيمة in Mawsoo‘ah al-Fiqhiyyah 44/32-35.