It is makrooh to interlace one's fingers when going out to pray, until one has prayed
Question

                What is the ruling on interlacing one's fingers when in the mosque?.
Praise be to Allah.
    This is part of the etiquette of going out to the mosque, 
    concerning which it says in the Sunnah that one should not interlace the 
    fingers. 

    It was narrated from Thumaamah al-Hannaat that Ka’b ibn 
    ‘Ujrah saw him when he was heading towards the mosque. They met one another 
    and he said: he found me interlacing my fingers and told me not to do that, 
    and he said: The Messenger of Allaah  (peace and blessings of Allaah be 
    upon him) said: “When one of you does wudoo’ and does it well, then goes out 
    heading to the mosque, let him not interlace his fingers, for he is in a 
    state of prayer.” Narrated by Abu Dawood, 562; classed as saheeh by 
    al-Albaani in Saheeh Abi Dawood. 
This hadeeth indicates 
    that it is not allowed to interlace the fingers when one is walking to the 
    mosque to pray, because the one who is headed towards the mosque comes under 
    the same ruling as one who is praying. 

    Al-Khattaabi (may Allaah have mercy on him) said: Interlacing 
    the fingers is something that some people do absent-mindedly, or some do it 
    to crack their fingers. A man may sit and interlace his fingers and wrap his 
    hands around his knees (whilst seated) in order to relax or try to sleep, so 
    it may cause him to lose his wudoo’. So it is said to the one who has 
    purified himself and set out towards the mosque: do not interlace your 
    fingers because all of the different things that we have mentioned do not 
    befit the prayer or the state of the one who is praying. End quote from 
    Ma’aalim al-Sunan, 1/295.

     In the hadeeth of Abu Hurayrah about the story of 
    Dhu’l-Yadayn and the topic of the prostration of forgetfulness, it says: “He 
    went and stood by a piece of wood that was set up in the mosque, and leaned 
    against it as if he was angry, and he placed his right hand on his left and 
    interlaced his fingers…” Narrated by al-Bukhaari, 482; Muslim, 573. 

    There is no contradiction between this and what we have 
    mentioned above, because this instance of interlacing the fingers came after 
    the Prophet  (peace and blessings of Allaah be upon him) thought the 
    prayer was over, so it comes under the ruling of one who has finished 
    praying. The prohibition applies only to the one who is praying and the one 
    who is heading towards the mosque, because it is a kind of fidgeting and not 
    focusing with proper humility. 

    Imam al-Bukhaari (may Allaah have mercy on him) said: 
    “Chapter on interlacing the fingers in the mosque and elsewhere” and he 
    narrated ahaadeeth from the Prophet  (peace and blessings of Allaah be 
    upon him) which show that he interlaced his fingers in the mosque and 
    elsewhere, including the hadeeth about Dhu’l-Yadayn mentioned above. 

    Al-Haafiz Ibn Hajar said, reconciling between these ahaadeeth 
    and the ahaadeeth which speak of the prohibition: 
Al-Ismaa’eeli reconciled 
    between them by noting that the prohibition is limited to when one is in 
    prayer or is intending to pray, because the one who is waiting for the 
    prayer comes under the same ruling as one who is praying… Then al-Haafiz 
    said: The report which says that this is forbidden so long as one is in the 
    mosque is da’eef (weak) as we have stated above. End quote. 

    Fath al-Baari, 1/565 

    It is worth noting that there are some worshippers who fidget 
    with their fingers by cracking them, but this fidgeting does not befit one 
    who is praying as it is indicative of a lack of proper focus and humility, 
    because if the heart is focused, the limbs will also be focused and be 
    still. 

    It was narrated that Shu’bah, the freed slave of Ibn ‘Abbaas, 
    said: I prayed beside Ibn ‘Abbaas and cracked my fingers. When the prayer 
    was over he said: “May you be bereft of your mother! You crack your fingers 
    when you are in prayer?” Narrated by Ibn Abi Shaybah, 2/344. al-Albaani said 
    in Irwa’ al-Ghaleel (2/99): its isnaad is hasan. 

    Conclusion: Interlacing the fingers is makrooh for one who is 
    going out to pray, until he has finished the prayer. If a person is sitting 
    in the mosque, there is nothing wrong with him interlacing his fingers 
    unless he is waiting for the prayer, in which case it is makrooh for him to 
    interlace them. 

    And Allaah knows best. 

    See: Ahkaam Hudoor al-Masaajid by Shaykh ‘Abd-Allaah 
    ibn Saalih al-Fawzaan, p. 67-68.