Ask two your friends' names.

Ask two of your friends' names.
Ask the names of two friends of yours.

------------------------------
Which expression is grammatical?

The first sentence is definitely wrong.

The other two don't make a lot of sense. Don't you already know your friends' names?

If this is an exercise for beginning English students, you might say, Ask two classmates what their names are.