This could work:
Test Custom Locator
[Arguments] ${browser} ${locator} ${tag} ${constraints}
${e} Get WebElements //*[@data-testid="${locator}"]
[Return] ${e}
But there might be otter problems with assert keywords.
Instead of using the custom locator, you could build easily this as plugin.