Mr Beattie quit after being arrested and released without charge by Police Scotland amid an investigation into the party's finances.
He was replaced temporarily by leader Humza Yousaf.
Mr McDonald, a former lawyer, was selected by party's National Executive Committee (NEC) and will remain in the post until the next annual conference.
The MP for Cumbernauld, Kilsyth and Kirkintilloch East said: "Whilst it is a difficult and challenging time, I look forward to getting on with the job of national treasurer to help take forward the important work being led by our new party leader, Humza Yousaf, to improve the SNP's governance and transparency."I've no hesitation in stepping forward when asked to do my part in keeping our party firmly on a campaign footing as the case for Scottish independence becomes more compelling than ever."
Mr Beattie also stepped away from his role on Holyrood's public audit committee until the police investigation had concluded.
The MSP was taken into custody and released without charge on Tuesday.
Mr Yousaf described his decision to resign as "the right thing to do".
A key task for the new treasurer will be appointing auditors after accountants Johnston Carmichael, which worked with the SNP for more than a decade, resigned around September.
The party's accounts are due to be filed to the Electoral Commission in July.
Mr McDonald has held several jobs for the party at Westminster, and is currently the party's justice and immigration spokesman.
SNP business convener Kirsten Oswald MP described him as an excellent appointment who is "widely respected" among the party.
She said: "I'm very glad members of the NEC were able to meet so quickly to agree the appointment of a new registered treasurer and give reassurance to SNP members that the activities of the party continue unabated."
MP Joanna Cherry, who has been a persistent critic of how the SNP has been run in recent years, has also welcomed Mr McDonald's appointment.
She told the BBC he is "thoroughly decent, very hard working and well respected across the party".
The date of the SNP's 19th annual conference has not been confirmed. Last year's event was held in October.
Police Scotland launched its Operation Branchform investigation into the SNP's finances in July 2021 after receiving complaints about how donations were used.
Former SNP chief executive Peter Murrell, who is married to former SNP leader and first minister Nicola Sturgeon, was arrested about two weeks ago at the couple's home in Glasgow.
He was released without charge pending further inquiries.
Officers spent two days searching the house, and also searched the SNP's headquarters in Edinburgh.
There have been newspaper reports that some people within the party are concerned that Ms Sturgeon could be the next person to be arrested in the inquiry.
Deputy First Minister Shona Robison, a close friend of Ms Sturgeon, said earlier this week that it would not be helpful to comment on the speculatio.
She added she did not know if Ms Sturgeon had spoken to detectives.
Mr Yousaf has rejected calls for Ms Sturgeon, Mr Murrell and Mr Beattie to be suspended from the party while police carry out their investigations.
He said he believes in people being innocent until proven guilty.
The SNP raised £666,953 through referendum-related appeals between 2017 and 2020. The party said these these funds were ring-fenced for independence campaigning.
Questions were raised after its accounts showed it had just under £97,000 in the bank at the end of 2019, and total net assets of about £272,000.
Police Scotland officers spent two days searching Ms Sturgeon and Mr Murrell's Glasgow home and the party's headquarters in Edinburgh earlier this month.
A luxury motorhome was seized by officers from outside a property in Dunfermline on the same morning Mr Murrell was arrested.
The Mail on Sunday reported that the vehicle had been parked outside the home of Mr Murrell's 92-year-old mother since January 2021. It has since been moved to a police compound in Glasgow.
Leaked video footage published by the Sunday Mail at the weekend showed Ms Sturgeon playing down fears about the party's finances in a virtual meeting of the party's ruling body in March 2021.
The SNP's former Westminster leader, Ian Blackford, has insisted that there was "nothing untoward" in the clip and claimed that the party's finances are in "robust health".
But the Sunday Times reported Mr Beattie told the NEC at the weekend that the SNP was struggling to balance its books due to a drop in member numbers and donors.