Yes, you can change the replication factor of the file as well as the directory. Use the below commands:
hdfs dfs –setrep –w 4 /dir/file.txt
hdfs dfs -setrep -R 4 /dir
But the important thing to keep in mind is altering the replication factor will only change the replication of the file which is already present. But the new file will be created by the default replication.