For that, don't use addElement. Use insertElementBefore.
Here is an example picked at random from the code https://github.com/moodle/moodle/blob/511a87f5fc357f18a4c53911f6e6c7f7b526246e/badges/classes/form/badge.php#L80
Here is an example picked at random from the code https://github.com/moodle/moodle/blob/511a87f5fc357f18a4c53911f6e6c7f7b526246e/badges/classes/form/badge.php#L80