This is a difficult outcome to achieve, but not impossible.
Now with a caveat that I researched and started a TL set in Burma some 5 years ago, but I am relying entirely from my memory here.
First off the Brits actually offered the Burmese a status quo peace in OTL and the Burmese themselves were the aggressors. Be that as it may the Burmese Army fought badly during the riverine part of the campaign so I would have Maha Bandula assume command of the Army earlier - really the only competent commander the Burmese have. Have the Army actually be able to use its muskets accurately and British losses increase commensurately as the forts that the Burmese had constructed were by all accounts quite sturdy.
The entire part of the riverine assault would be supplied by the river, so destroying the Royal Navy barges etc at anchor or in harbour would be your best best. You then have a land force that is isolated deep in the jungle... retreat from Afghanistan. However also remember after the retreat from Afghanistan the Brits formed the Army of Retribution so Burma isn't necessarily out of the woods yet.