How to change random number of random elements in a column by group in R?
The idea is correct, even if you have a couple of mistakes in your code (like id is not defined, and inside paste you want to use just n, not df$Name). This is not super compressed code but it does the job:

Name = c('Ed','Ed','Bill','Tom','Tom','Tom','Ed','Bill','Bill','Bill')
df = data.frame(Name)

for (n in unique(df$Name)){

    # get indices 
    indices = which(df$Name==n)

    # sample size
    samp_size = round(length(df[df$Name==n,])/2)

    # get indices to replace
    samp = sample(indices, samp_size)

    # need to set column as character
    df$Name = as.character(df$Name)

    # set new values
    df[samp,] =  paste(n,'_X',sep='')

    # set again column as factor 
    df$Name = as.factor(df$Name)
}


Out:

     Name
1      Ed
2    Ed_X
3    Bill
4   Tom_X
5   Tom_X
6     Tom
7    Ed_X
8    Bill
9  Bill_X
10 Bill_X