You can pass LIMIT values as arguments from code. Don't use "limit" as the value. And you cannot use a variable like "?limit" as the value either. You can, however, add something like LIMIT <> at the end where that value is placed as an integer via code.
Steve has provided the correct answer to your question. Using the .limit(..) method of the Query API is the only recommended way to specify the limit outside of the query string. The example he linked to is complete and shows how the method should be used.
I think you're using stardog-spring and for the future it'd help if you mention it explicitly. It's open source and if you look into the query method's code, you will see that it does not support setting the limit externally. You can fork the code and add this feature.
Otherwise you'd have to inject the limit value into your query string manually before using SnarlTemplate. Stuff like this is (in general) prone to injection attacks and we do not recommend it.