1. Get rid of tempTable.name_name = $2;
As @a_horse_with_no_name said, you should not be running multiple update statements. 
I see you are calling PERFORM costs_f($1, i) multiple times for each letter in someArr. Instead of calling it multiple times, call it once and use the in operator, e.g. :
AND tempTable.name_name in($2);
2. Split the Update into 2 Statements
You should split your update statement into two statements:
UPDATE ways 
SET cost_time = -1.0 FROM tempTable 
WHERE gid = id AND tempTable.name_name = $2 AND
$1 = -1.0 ;
UPDATE ways 
SET cost_time =anotherFloat * $1 FROM tempTable 
WHERE gid = id AND tempTable.name_name = $2 AND
NOT ($1 = -1.0) ;
Note: Simplified by only using tempTable  instead of the full nested subuery/alias
3. Move conditions into the nested Aliased From SubQuery
Right off the bat I can see you can move the condition name_name = $2 directly into the from aliased subquery:
FROM (SELECT w.gid AS id,
mc.name,
w.someCosts
FROM myTable mt
JOIN myClasses mc
ON mt.class_id = mc.class_id 
WHERE name_name = $2 ) AS tempTable
WHERE gid = id;
All Together
CREATE OR REPLACE FUNCTION update_costs_f(
someFloat float) RETURNS void AS
$$
DECLARE
someArr varchar[] := ARRAY['a', 'b', 'c', 'd',
    'e', 'f', 'g', 'h', 'i', 
    'j', 'k', 'l',
    'm', 'n', 'o', 'p', 
    'q', 'r', 's', 't', 'ul', 'v'];
i text;
BEGIN
PERFORM costs_f($1, someArr );
END
$$
language 'plpgsql';
CREATE OR REPLACE FUNCTION costs_f(
someFloat float) RETURNS void AS
$$
BEGIN
UPDATE ways 
SET cost_time = -1.0
FROM (SELECT w.gid AS id,
mc.name,
w.someCosts
FROM myTable mt
JOIN myClasses mc
ON mt.class_id = mc.class_id
WHERE $1 = -1.0 AND gid = id AND tempTable.name_name = ANY($2);
) AS tempTable;    
UPDATE ways 
SET cost_time =anotherFloat * $1 
FROM (SELECT w.gid AS id,
mc.name,
w.someCosts
FROM myTable mt
JOIN myClasses mc
ON mt.class_id = mc.class_id
WHERE NOT($1 = -1.0) AND gid = id AND tempTable.name_name =ANY($2);
) AS tempTable;
END
$$
language 'plpgsql';
Finally
You could use an IF statement in order to not run both SQL update statements...
See: PostgreSQL IF statement
Example:
IF ($1 = -1.0) THEN
   ...
ELSE 
  ...
END IF;