How can I edit the .bash_profile?
Try the following command:

chown $(id -u -n) ~/.bash_profile


Using the chown command in that way, you can be sure that is using your username (id -u -n).

Additionally, as @user3439894 says, if you get permission errors with previous command, your should add sudo before the command to execute the command as root:

sudo chown $(id -u -n) ~/.bash_profile


From id man page:


  id - print real and effective user and group IDs
  
  -n, --name: print a name instead of a number
  -u, --user: print only the effective user ID


From chown man page (suggested by @fd0):


  For obvious security reasons, the ownership of a file may only be altered by a super-user.