Replace elements of a list based on a function

To answer your question directly, a loop could be written like this:

f = Table[3*k*k, {k, 1, 16}];
Do[
  f[[4 i + j]] = 1;
  ,
  {i, {1, 3}},
  {j, 1, 4}
  ];
f

{3, 12, 27, 48, 1, 1, 1, 1, 243, 300, 363, 432, 1, 1, 1, 1}

A non-loop alternative is this:

f = Table[3*k*k, {k, 1, 16}];
pos = Flatten@Table[Range[4] + 4 n, {n, {1, 3}}];
f[[pos]] = 1;
f

{3, 12, 27, 48, 1, 1, 1, 1, 243, 300, 363, 432, 1, 1, 1, 1}

or similarly

f = Table[3*k*k, {k, 1, 16}];
pos = Flatten[Range[#, 16, 8] & /@ Range[5, 8]];
f[[pos]] = 1;
f

{3, 12, 27, 48, 1, 1, 1, 1, 243, 300, 363, 432, 1, 1, 1, 1}


Join @@ MapAt[ConstantArray[1, 4] &, Partition[f, 4], {2 ;; ;; 2}]

With[{mask = 1 - Mod[Quotient[Range@16, 4, 1], 2]}, mask f + 1 - mask]

SubsetMap[1 & /@ # &, f, Join @@ Partition[Range[16], 4, 8, 5]]

With[{p = Join @@ Partition[Range[16], 4, 8]}, Normal@SparseArray[p -> 3 p^2, 16, 1]]

all give

{3, 12, 27, 48, 1, 1, 1, 1, 243, 300, 363, 432, 1, 1, 1, 1}

g[k_Integer] := 3 k^2 /; MemberQ[{1, 2, 3, 4}, Mod[k, 8, 1]];
g[k_Integer] := 1 /; MemberQ[{5, 6, 7, 8}, Mod[k, 8, 1]];
g /@ Range[256]