How can I use function's parameter in it?
Certain parts of queries cannot be substituted like that.  Such parts include table names and keywords.  "WEEK" fall into this category.  Instead...

-- Construct the query:
SET @sql = CONCAT("SELECT ... INTERVAL 1 ", range, "))");
-- perform it:
PREPARE _query FROM @sql;
EXECUTE _query;
-- clean up:
DEALLOCATE PREPARE _query;


(This will probably be more efficient than some IF..THEN..ELSE or CASE..WHEN construct.)