JSON Path allows to specify a negative array index, eg $[-1] returns the last element. This is not supported in MariaDB.
Because of this, I believe there is no way to retrieve the last element without knowing the array length, nor to insert (JSON_ARRAY_INSERT()) an element at the end of the array. If I'm correct, this is a major missing feature for those who use JSON functions.
UPDATE: The task includes adding the negative index and the new keyword "last"