I always think of using trim when I want to do this action but you don’t use trim you use substring to remove characters from a string like so:

substring('hello world', 6, 5)

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#substring

Reference:
https://powerusers.microsoft.com/t5/General-Power-Automate/Removing-the-last-character-in-the-string/td-p/141940