is it okay to ask them to sponsor my travel?
It's always ok to ask.
If it is okay, then how can I ask them? Before interview or after
interview? What should I say specifically?
You should ask before the interview, typically when you are settling on a time, date, and location.
Just ask "This interview is going to involve some travel, lodging, and food expense on my part. What is your policy on reimbursing interview expenses?"
Then pay attention to the response. Make sure you know what the company will and won't pay for, and what you are expected to do in order to be reimbursed.
Some companies have special lodging arrangements, and will want you to stay in particular hotels, for example.
You want to make sure you can follow their rules precisely. it won't look good for you if you submit for expenses that they didn't tell you could be reimbursed. It might make you look as if you can't follow instructions, and may diminish your candidacy.
If you neglected to establish what their reimbursement rules while planning your interview, the best you can do now is try and ask now - before the expenses occur, and certainly before the interview. It's unfortunate, but the best you can do.