You can use the following mapping:
inoremap <CR> <Esc>:pyf ~/clang-format.py<CR>o
Which can be explained like this:
The mapping command:
inoremap creates a mapping in insert mode
The left hand part:
<CR> you want to map the 'enter' key and its code is <CR>
The right hand part:
<Esc> exit insert mode
:pyf ~/clang-format.py write the command to execute
<CR> press 'enter' to execute the command
o pressing 'o' in normal mode will add a new line and switch to insert mode
In the comments you asked why it doesn't work in paste mode. It is normal you can't create mapping in paste mode it would defeat the purpose of this mode. See this question on SO.
Finally a note on the efficiency of your workflow: I might be wrong but if I understand correctly you want to reformat all of your file each time you insert a new line. That doesn't seem ideal since Vim as some options to help you format your code as you right it. Now as I don't really know what your command does maybe it is the best solution.
EDIT To answer your comment, if you want to trigger the command only when you exit insert mode when editing a python file you can use autocommands:
autocmd! InsertLeave *.py pyf ~/clang-format.py