You really only have one option when it comes to sensitive data, not just in Loki, in any data storage platform, and that is to redact the sensitive part of your logs and data before sending it to your storage.
How secure will be a query with “replace”?
Only visually. Average user can play with browser console and remove that “replace” from the query to get sensitive nonreplaced data.