It’s not clear that that’s your issue. But, you should set the system-wide LANG /etc/locale.conf or maybe localectl. I’m not entirely sure, but you’d need to set it for root because this is all executed by apach running sudo, so basically you’re safest bet to change it is to just change it on the entire system.
But again, I don’t think that’s the issue because that name abdelali.elkouri appears to be just fine in US ascii (even you say you can manually run the command and it works) I cannot replicate by running LANG=en_US.US-ASCII sudo /usr/bin/env ruby .... My guess is is there’s some white space characters that your not seeing like ^M.
In terms of debugging maybe you can redirect the names to a file and use cat -e to see if there’s something funny there. Or use curl to interact with Dex and extract the usernames from there (if this is your account).