Your etymology is essentially correct. The Middle English "bougre" meant primarily a heretic, but the Bulgarian/Bogomil heretics were also accused of sodomy. So one thing led to another.
Does anyone know anything about the familiar American tune as sung by Ives, Carl Sandburg, and everyone else?