I am a bankruptcy attorney and I would be happy to assist you. The bankruptcy rules
are specific on this issue. In order to file bankruptcy in any state in the USA, you need to live in that state for at least 180 days. (28 USC § 1408) So you can not file bankruptcy in the US from Canada. As you are still a US citizen, if you still have a drivers license, primary address in the US and have maintained residency in any state, you could go ahead and begin the process of filing bankruptcy.
Although you need to qualify by living in the US state where you plan to file for 180 days, you can still meet with an attorney to begin preparing your paperwork. That way it is ready to file as soon as you qualify.
After you file bankruptcy it will remain on your US credit report for approximately 7 years. Most people believe it decreases your credit score, when it in fact typically increases it. This is because you will no longer have large amounts of debt to credit ratio. Although you may not qualify for large amounts of credit immediately preceding a bankruptcy and your interest may be higher, over time as you use credit wisely you will be able to rebuild your credit rating. Some lenders in Canada may review your US credit history or they may require you to build new credit from scratch in Canada, despite whether you file bankruptcy in the US or not. Typically a US bankruptcy will not appear on your Canadian credit report, but that doesn't mean that lenders and large companies will not review your US credit report.
I hope my answer has assisted you and that you will leave me a positive rating! If you have any follow up questions, please ask for me by name and I would be happy to assist you.